Solved

Selection.OnAction assignment from another workbook VBA

Posted on 2010-09-05
1
1,291 Views
Last Modified: 2012-06-21
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
0
Comment
Question by:irwinconsult
1 Comment
 
LVL 11

Accepted Solution

by:
jkpieterse earned 500 total points
ID: 33609146
If the macro you're calling is in the same workbook as the code that creates it:

Selection.OnAction = "'" & ThisWorkbook.FullName & "'!create_new_pan"

Note the single quotes!
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now