仅用于在 Excel 中为当前工作簿禁用右键单击选项的 VBA 代码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23206328/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
VBA Code for disable the Right Click option in Excel for the current Workbook only
提问by user2095503
I have created multiple worksheets in my workbook.
I want to my users are not allowing to see the other sheets in excel.
Since I want to disable the right click option in Excel open event.
我在我的工作簿中创建了多个工作表。
我希望我的用户不允许在 excel 中查看其他工作表。
因为我想在 Excel 打开事件中禁用右键单击选项。
I have a piece of code:
我有一段代码:
Private Sub Workbook_SheetBeforeRightClick (ByVal Sh As Object, ByVal Target As Range, Cancel As Boolean)
Cancel = True
MsgBox ("Sorry Right Click is Disabled for this Workbook")
End Sub
The above code runs only after opening the Workbook and run the Macro.
I want to disable right click option the Workbook when opening the Workbook.
上面的代码仅在打开工作簿并运行宏后运行。
我想在打开工作簿时禁用工作簿的右键单击选项。
回答by Chris
Try this, different parameters...
试试这个,不同的参数...
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True
End Sub
回答by Ah Chang Munelith
you can try the codes below: - Good Luck
你可以试试下面的代码: - 祝你好运
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.CommandBars("Ply").Enabled = True
End Sub
And
和
Private Sub Workbook_Open()
Application.CommandBars("Ply").Enabled = False
End Sub