我在工作簿中创建了多个工作表
我想我的用户不允许在excel中看到其他表。
因为我想在Excel打开事件中禁用右键单击选项。
我有一段代码:
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
上述代码仅在打开工作簿并运行宏后运行 我想在打开工作簿时禁用工作簿的右键单击选项。
答案 0 :(得分:3)
试试这个,不同的参数......
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True
End Sub
答案 1 :(得分:-1)
你可以尝试下面的代码: - 祝你好运
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.CommandBars("Ply").Enabled = True
End Sub
和
Private Sub Workbook_Open()
Application.CommandBars("Ply").Enabled = False
End Sub