Excel单元格上下文菜单 - 宏

时间:2016-12-07 14:20:39

标签: excel menu cell

我在Excel单元格上下文菜单中添加了一个宏。

这是主要代码,

Private Sub Workbook_Open()
Dim NewControl As CommandBarControl
    Application.CommandBars("Cell").Reset
   Set NewControl = Application.CommandBars("Cell").Controls.Add
    With NewControl
      .Caption = "Inserir Data"
      .OnAction = "Module1.OpenCalendario"
      .BeginGroup = True
    End With
End Sub

在这里你可以看到结果,

Excel Cell Context Menu

无论如何,将这个宏放在菜单的顶部?

1 个答案:

答案 0 :(得分:1)

尝试:

Set NewControl = Application.CommandBars("Cell").Controls.Add(before:=1)