Problem calling macro from a commandbar

T

Trefor

In a module of a xla:

Sub Create_DCA_Menu()
Dim mynewbar, button1, button2, button3
Set mynewbar = CommandBars(1).Controls.Add(Type:=msoControlPopup,
Temporary:=True)
With mynewbar
.Caption = "DCA Menu"
End With
Set button1 = mynewbar.Controls.Add(Type:=msoControlButton)
With button1
.Caption = "Open Menu"
.OnAction = ThisWorkbook.Name & "!Open_Menu"
End With
End Sub

When I select the command bar button1 it tries to run "Open_Menu" in a
different xla.

I have multiple XLA files at different versions and they all have this same
Sub. Even though I specified ThisWorkbook.Name it still goes to the other
xla. What am I doing wrong?
 

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

Top