VBA命令按钮操作

1、添加一个命令按钮SubAddCommandBar()’命令DimcbarAsCommandBarButtonSetcbar=CommandBars(“Standard”).Controls(“临时按钮”)IfNotcbarIsNothingThenExitSubEndIfWithCommandBars(“Standard”).Protection=msoBarNoProtectionWith.Controls.Add(msoControlButton,Before:=3).DescriptionText=”QuitWithoutSave”.Caption=”临时按钮”.TooltipText=”临时按钮”.Style=msoButtonIconAndCaption.OnAction=”QuitWithoutSave”EndWithEndWithEndSubPrivateSubQuitWithoutSave()MsgBox”激活事件:临时按钮”EndSub2、删除命令按钮CommandBars(“Standard”).Controls(“临时按钮”).Delete

3 修改word命令

‘修改word命令SubFileSave()MsgBoxActiveDocument.NameIfActiveDocument.Saved=FalseThenActiveDocument.SaveEndIfEndSubSubFileSaveAs()MsgBox”您不能另存文档”EndSub

4、删除顶端菜单

CommandBars.ActiveMenuBar.Controls(“Custom”).Delete你会发现,曾经以为很难做到的事情,

VBA命令按钮操作

相关文章:

你感兴趣的文章:

标签云: