Selection.OnAction assignment from another workbook VBA
Posted on 2010-09-05
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:
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.