Customizing a ribbon with VBA in Excel

前端 未结 1 1697
渐次进展
渐次进展 2021-01-01 01:26

I\'ve already learned that creating a custom tab is in Excel not possible in this! post (unlike i.e. MSProject)

Specifically, can I change the paths of the macros to

相关标签:
1条回答
  • 2021-01-01 02:07

    This is some code I use to add a custom toolbar:

    Set cbToolbar = Application.CommandBars.Add(csToolbarName, msoBarTop, False, True)
    
    With cbToolbar
        Set ctButton1 = .Controls.Add(Type:=msoControlButton, ID:=2950)
        Set ctButton2 = .Controls.Add(Type:=msoControlButton, ID:=2950)
        Set ctButton3 = .Controls.Add(Type:=msoControlButton, ID:=2950)
    End With
    
    With ctButton1
        .Style = msoButtonIconAndCaption
        .Caption = "Set &Picklists"
        .FaceId = 176
        .OnAction = "SetPicklist"
    End With
    
    With ctButton2
        .Style = msoButtonIconAndCaption
        .Caption = "Set &Defaults"
        .FaceId = 279
        .OnAction = "SetDefaults"
    End With
    
    With ctButton3
        .Style = msoButtonIconAndCaption
        .Caption = "&Visibility Settings"
        .FaceId = 2174
        .OnAction = "VisibilitySettings"
    End With
    
    
    With cbToolbar
        .Visible = True
        .Protection = msoBarNoChangeVisible
    End With
    

    The 'OnAction' controls the macro that runs... If you wanted to expand that to run a macro on a specific workbook, use "whatever.xls!MacroName"

    0 讨论(0)
提交回复
热议问题