1、屏蔽“菜单”中的项:
Application.CommandBars(1).Controls("文件(&F)").Enabled = False '屏蔽文件菜单
Application.CommandBars(1).Controls("编辑(&E)").Enabled = False '屏蔽编辑菜单
Application.CommandBars(1).Controls("视图(&V)").Enabled = False '屏蔽视图菜单
Application.CommandBars(1).Controls("插入(&I)").Enabled = False '屏蔽插入菜单
Application.CommandBars(1).Controls("格式(&O)").Enabled = False '屏蔽格式菜单
Application.CommandBars(1).Controls("工具(&T)").Enabled = False '屏蔽工具菜单
Application.CommandBars(1).Controls("数据(&D)").Enabled = False '屏蔽数据菜单
Application.CommandBars(1).Controls("窗口(&W)").Enabled = False '屏蔽窗口菜单
Application.CommandBars(1).Controls("帮助(&H)").Enabled = False '屏蔽帮助菜单
2、屏蔽“菜单”中的子项:
Application.CommandBars(1).Controls("编辑(&E)").Controls("填充(&I)").Enabled = False '屏蔽“编辑”菜单中的“填充”项
Application.CommandBars(1).Controls("工具(&T)").Controls("选项(&O)...").Visible = False '去除工具-选项
Application.CommandBars(1).Controls("工具(&T)").Controls("选项(&O)...").Enabled = False '工具-选项变灰色
3、禁用粘贴:
Application.CommandBars("Cell").Controls("粘贴(&P)").Enabled = False '禁用右键粘贴
Application.CommandBars("Cell").Controls("选择性粘贴(&S)...").Enabled = False
Application.CommandBars(1).Controls("编辑(&E)").Controls("粘贴(&P)").Enabled = False
Application.CommandBars(1).Controls("编辑(&E)").Controls("选择性粘贴(&S)...").Enabled = False
Application.CommandBars(1).Controls("编辑(&E)").Controls("office 剪贴板(&B)...").Enabled = False
Application.CommandBars(3).Controls("粘贴(&P)").Enabled = False
Application.CommandBars.DisableCustomize = True
4、其他
Application.CommandBars(1).Controls("工具(&T)").Controls("自定义(&C)...").Enabled = False
Application.OnKey "^v", "" '禁用键盘"Ctrl+V"
Application.OnKey "^v" '恢复键盘"Ctrl+V"
Application.CommandBars.DisableAskAQuestionDropdown = True '去除工作表右上角的帮助栏
Application.CommandBars("Reviewing").Visible = False '屏蔽审阅
Application.CommandBars("Formula Auditing").Visible = False '屏蔽公式审核
Application.CommandBars("Control Toolbox").Visible = False '屏蔽控件工具箱
Application.CommandBars("Stop Recording").Visible = False '屏蔽录制宏
Application.CommandBars("Forms").Visible = False '屏蔽窗体
Application.CommandBars("Drawing").Visible = False '屏蔽绘图
5、屏蔽/解除整段代码:
视图-》工具栏-》编辑,选中代码,然后在编辑的工具栏里“设置注释块和“解除注释块”按钮
Application.EnableCancelKey = xlDisabled '应用程序的EnableCancelKey=完全禁用“取消”键捕获功能
Application.EnableCancelKey = xlInterrupt '应用程序的EnableCancelKey=中断当前运行程序,用户可进行调试或结束程序的运行