ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Problem calling macro from a commandbar (https://www.excelbanter.com/excel-programming/358012-problem-calling-macro-commandbar.html)

Trefor

Problem calling macro from a commandbar
 
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?

--
Trefor


All times are GMT +1. The time now is 02:00 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com