Link to home
Start Free TrialLog in
Avatar of irwinconsult
irwinconsult

asked on

Selection.OnAction assignment from another workbook VBA

Experts,

I am running an Excel 2007 addin file "Irwinconsult Menu.xlam" which contains a section of script to assign a macro to a button contained within another excel workbook (the macro being assigned to the button is also contained within the other workbook).  Part of the code is as follows:

Windows(New_Pan_Workbook).Activate
ActiveSheet.Shapes("Button 115").Select
Selection.OnAction = "create_new_pan"

Note:  New_Pan_Workbook is assigned as the part of the other workbook earlier in the code.  

The problem with the Selection.OnAction script above is the because it is executed by Irwinconsult Menu.xlam, the button assignment ends up being "'Irwinconsult Menu.xlam'!create_new_pan"  instead of simply "create_new_pan".  

The other complication is that the name and path of the other workbook varies but this is dealt with using the  ActiveWorkbook.Path and .Name earlier in the code.

Any thoughts?

Jason
ASKER CERTIFIED SOLUTION
Avatar of Jan Karel Pieterse
Jan Karel Pieterse
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial