E
EagleOne
Excel 2003 & 2007 up to date
The code below was obtained from vbaexpress as noted. I modified it for my specifics.
For hours, I attempted to create a distinct Command Bar Menu "Set" of controls to no avail.
In short, my Add-Ins Tab in 2007 has two sections in the Menubar: ""Menu Commands" (which contains
5 dropdrown controls) and "Custom Toolbars" (which contains 3 .pdf controls). I would like my
menu item "&VBA Setup" to be in a separate section like ""Menu Commands" and "Custom Toolbars"
Thus 3 SECTIONS i.e. "Custom Toolbars;" "Custom Toolbars;" and "VBATools"
What code lines am I missing?
Any thoughts greatly appreciated.
***********************************************************************************************
CODE NEXT
***********************************************************************************************
Private Sub Workbook_Open()
' http://www.vbaexpress.com/kb/getarticle.php?kb_id=427#instr
' 3/22/2010
Dim cmbBar As CommandBar
Dim cmbControl As CommandBarControl
Set cmbBar = Application.CommandBars("Worksheet Menu Bar")
If cmbBar.Controls(cmbBar.Controls.count).Caption <> "" Then
Set cmbControl = cmbBar.Controls.Add(Type:=msoControlButton, Temporary:=True)
End If
Set cmbControl = cmbBar.Controls.Add(Type:=msoControlPopup, Temporary:=True) 'adds a menu item
With cmbControl
.Caption = "&VBA Setup" 'names the menu item
With .Controls.Add(Type:=msoControlButton) 'adds a dropdown button to the menu item
.Caption = "Add-Ins Install" 'adds a description to the menu item
.OnAction = "ToolsInitDLL.AddinsInstall" 'runs the specified macro
.FaceId = 220 'assigns an icon to the dropdown
End With
With .Controls.Add(Type:=msoControlButton)
.Caption = "Add-Ins Un-Install"
.OnAction = "ToolsInitDLL.AddInsUninstall"
.FaceId = 220
End With
With .Controls.Add(Type:=msoControlButton)
.Caption = "Apply Macro Shortcuts"
.OnAction = "ToolsInitDLL.ApplyShortCuts"
.FaceId = 220
End With
With .Controls.Add(Type:=msoControlButton)
.Caption = "VB Library References"
.OnAction = "ToolsInitDLL.ListObjLibReferences"
.FaceId = 220
End With
End With
End Sub
The code below was obtained from vbaexpress as noted. I modified it for my specifics.
For hours, I attempted to create a distinct Command Bar Menu "Set" of controls to no avail.
In short, my Add-Ins Tab in 2007 has two sections in the Menubar: ""Menu Commands" (which contains
5 dropdrown controls) and "Custom Toolbars" (which contains 3 .pdf controls). I would like my
menu item "&VBA Setup" to be in a separate section like ""Menu Commands" and "Custom Toolbars"
Thus 3 SECTIONS i.e. "Custom Toolbars;" "Custom Toolbars;" and "VBATools"
What code lines am I missing?
Any thoughts greatly appreciated.
***********************************************************************************************
CODE NEXT
***********************************************************************************************
Private Sub Workbook_Open()
' http://www.vbaexpress.com/kb/getarticle.php?kb_id=427#instr
' 3/22/2010
Dim cmbBar As CommandBar
Dim cmbControl As CommandBarControl
Set cmbBar = Application.CommandBars("Worksheet Menu Bar")
If cmbBar.Controls(cmbBar.Controls.count).Caption <> "" Then
Set cmbControl = cmbBar.Controls.Add(Type:=msoControlButton, Temporary:=True)
End If
Set cmbControl = cmbBar.Controls.Add(Type:=msoControlPopup, Temporary:=True) 'adds a menu item
With cmbControl
.Caption = "&VBA Setup" 'names the menu item
With .Controls.Add(Type:=msoControlButton) 'adds a dropdown button to the menu item
.Caption = "Add-Ins Install" 'adds a description to the menu item
.OnAction = "ToolsInitDLL.AddinsInstall" 'runs the specified macro
.FaceId = 220 'assigns an icon to the dropdown
End With
With .Controls.Add(Type:=msoControlButton)
.Caption = "Add-Ins Un-Install"
.OnAction = "ToolsInitDLL.AddInsUninstall"
.FaceId = 220
End With
With .Controls.Add(Type:=msoControlButton)
.Caption = "Apply Macro Shortcuts"
.OnAction = "ToolsInitDLL.ApplyShortCuts"
.FaceId = 220
End With
With .Controls.Add(Type:=msoControlButton)
.Caption = "VB Library References"
.OnAction = "ToolsInitDLL.ListObjLibReferences"
.FaceId = 220
End With
End With
End Sub