Command button to run external macro

lipanook

New Member
Joined
Nov 29, 2012
Messages
23
I'm trying to create a command button within a worksheet that runs a macro from a different addin.

The buttin is created as part of a VBA macro. I can get it to work with macros that exist in the same addin to the one creating the buttion:

Code:
ActiveSheet.Buttons.Add(320, 380, 50, 40).Select
Selection.Name = "btnRunMacro1"
Selection.OnAction = "macro1"
ActiveSheet.Shapes("btnRunMacro1").Select
Selection.Characters.Text = "Run macro 1"

But I can't make it run a macro from a different addin:

Code:
otherAddin = "C:\Excel Addins\OtherAddin.xlam"

ActiveSheet.Buttons.Add(390, 380, 50, 40).Select
Selection.Name = "btnExternalMacro"
Selection.OnAction = otherAddin & "'!macro1'"
ActiveSheet.Shapes("btnExternalMacro").Select
Selection.Characters.Text = "Run external macro 1"

All I get is a command button that I can't click on (I can only 'select' it).

Any ides?
 

Some videos you may like

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Watch MrExcel Video

Forum statistics

Threads
1,109,540
Messages
5,529,434
Members
409,876
Latest member
Akash Yadav
Top