Custom commandbar via VBA


Dale Fye

Access 2003 (SP2)

I'm working on creating some custom commandbars using VBA (I had to do this
recently while working in Excel because I could not figure out how to create
the toolbar as a popup using the View - Toolbars - Customize dialog box).

I like this method as it provides more flexibility (create my own menu
items, including dropdown and textbox), and the ability to easily copy the
code from one application to another. Plus, the code sits in a module rather
than in the command bars collection.

You have to have a reference to the Office 12 Object Library for this to
work, but I'm working on modifications for late binding. I've created a test
popup menu that I'm currently testing by calling it in the Immediate window:

Call ArcCheckMenu

When I show this popup menu, and click on the dropdown item, the items in
the list show up to the right of the combo box rather than directly below it.
Does anyone have any idea why, or how to resolve this?

Public Sub ArcCheckMenu()

Dim cbr As CommandBar

Dim cbrCombo As CommandBarComboBox
Dim cbrEdit As CommandBarControl
Dim cbrButton As CommandBarButton

On Error Resume Next
On Error GoTo ArcCheckError

Set cbr = CommandBars.Add("CheckMenu", msoBarPopup, , True)

With cbr
Set cbrCombo = cbr.Controls.Add(msoControlComboBox, , , , True)
With cbrCombo
.AddItem "2 Nodes"
.AddItem "3 Nodes"
.DropDownWidth = 70
.Caption = "Circular Reference"
'.OnAction = "=fnCircularRef()"
.Tag = .Caption
End With

Set cbrEdit = cbr.Controls.Add(msoControlEdit, , , , True)
With cbrEdit
.Width = 50
.Text = "Now is the time"
.Caption = "test"
'.OnAction = "fnDoSomething()
.Tag = .Caption
End With

End With

Exit Sub


Debug.Print "ArcCheckMenu" & vbCrLf & Err.Number & vbCrLf &
Resume Next

End Sub
Dec 31, 2016
Reaction score
Were you able to find a work around for the issue described in this post? I would like to be able to have a ComboBox in a Popup Menu as well.


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question