我们使用Windows 10/64位MS Office 365 /2016.

问题描述 投票:0回答:1

您的代码更改了

Normal


Page Layout

的内容菜单。但这不会更改
Page Break Preview
的菜单。
excel vba user-defined-functions add-in right-click
1个回答
0
投票
    内容菜单名称为
  • Cell

    在M365
    上进行了测试
    
    

  • pleasetry.

  • Public Sub AddItemToCellMenu() Dim cmdBar As CommandBar, cmdPopup As CommandBarPopup, cmdButton As CommandBarButton On Error GoTo ErrorHandler: For Each cmdBar In Application.CommandBars If cmdBar.Name = "Cell" Then cmdBar.Reset Set cmdPopup = cmdBar.Controls.Add(Type:=msoControlPopup, Before:=1) With cmdPopup .Caption = "My Popup" End With Set cmdButton = cmdPopup.Controls.Add(Type:=msoControlButton) With cmdButton .Caption = "This is my macro1" .OnAction = "Mymacro1" .FaceId = 370 End With Set cmdButton = cmdPopup.Controls.Add(Type:=msoControlButton, Before:=1) With cmdButton .Caption = "This is my macro2" .OnAction = "Mymacro2" .FaceId = 370 End With End If Next Exit Sub ErrorHandler: Debug.Print Err.Number & " " & Err.Description End Sub
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.