Assign Macro to Command Button doesn't work

C

CLS

Hi All,

I am trying to assign a custom macro to a custom command button I have
inserted into my menu bar. When I click on assign macro, there is no
listing of my custom macros I have created in VBA (custom .xla file). So I
type the macro name in. (Main.myMacro)

When I click on the button it says "book1.xls'Main.myMacro" does not exist.

of course not it is in myAddin.xla.

So I change it to myAddin.xla'Main.myMacro and it says it cannot open this
file because it is already open.

I have an old button that works with just Main.MyotherMacro. But if I type
Main.MyMacro it automatically changes it to "book1.xls'Main.myMacro" once I
close it.

I cannot remember how I got the other to work.

Please Help
Chad
 
C

Chip Pearson

Set the IsAddin property of your addin to False, assign the macro
to the command button, and the set the IsAddin property to True.
To set the property, go to the VBA editor, open the Immediate
Window (CTRL+G) and enter

ThisWorkbook.IsAddin = False ' then True to restore


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
C

CLS

Worked Great
Thanks

Chip Pearson said:
Set the IsAddin property of your addin to False, assign the macro to the
command button, and the set the IsAddin property to True. To set the
property, go to the VBA editor, open the Immediate Window (CTRL+G) and
enter

ThisWorkbook.IsAddin = False ' then True to restore


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 

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