我花了很多时间才找到解决方案而没有成功。 我尝试在右键单击菜单中添加自定义操作,但是当我在单元格中键入时,在编辑模式下。 所有主题都解释了如何在右键单击菜单中添加操作,但仅当您选择一个单元格而不是当您在其中时。
这是我个人的右键菜单
在版本模式下右键单击时的上下文菜单:
我的标准右键菜单代码:
Public Function addMenu(menuName As String, menuActionMacro As String, pictureFaceId As Integer, beginGroup As Boolean)
If checkMenuNotExist(menuActionMacro) Then
Dim cbButt As CommandBarButton
Dim cb As CommandBar
Set cb = Application.CommandBars("cell")
Set cbButt = cb.Controls.Add(msoControlButton, Temporary:=True)
cbButt.beginGroup = beginGroup
cbButt.Caption = menuName
cbButt.OnAction = menuActionMacro
cbButt.FaceId = pictureFaceId
cbButt.Tag = menuActionMacro
End If
End Function
有人如何在编辑右侧菜单中添加操作?
答案 0 :(得分:1)
我使用了我的MenuRighter加载项,以及它的"在菜单上显示标签"确定您感兴趣的上下文菜单是#58并且被称为" Formula Bar"。我没想到会有一个变化,但我能够将文件菜单添加到它。
所以试试这个:
Public Function addMenu(menuName As String, menuActionMacro As String, pictureFaceId As Integer, beginGroup As Boolean)
If checkMenuNotExist(menuActionMacro) Then
Dim cbButt As CommandBarButton
Dim cb As CommandBar
Set cb = Application.CommandBars("Formula Bar")
Set cbButt = cb.Controls.Add(msoControlButton, Temporary:=True)
cbButt.beginGroup = beginGroup
cbButt.Caption = menuName
cbButt.OnAction = menuActionMacro
cbButt.FaceId = pictureFaceId
cbButt.Tag = menuActionMacro
End If
End Function