Call macro from active workbook

J

John

I may have 2 or 3 workbooks open, each has a custom print macro that is
activated with Ctrl-P. However, Ctrl P does not call the macro from the
active workbook. Seems like I read somewhere when there are duplicate
shortcut keys, Excel calls macros from workbooks in alphabetical order. How
can I force Excel to call the macro from the active workbook? Thank you.
 
S

Simon Lloyd

You would be better off saving the macro in PERSONAL.xls then it woul
be available on the activeworkbook on demand

John;512523 said:
I may have 2 or 3 workbooks open, each has a custom print macro that i
activated with Ctrl-P. However, Ctrl P does not call the macro from th
active workbook. Seems like I read somewhere when there are duplicat
shortcut keys, Excel calls macros from workbooks in alphabetical order
Ho
can I force Excel to call the macro from the active workbook? Than
you

--
Simon Lloy

Regards
Simon Lloy
'Microsoft Office Help' (http://www.thecodecage.com
 
J

JLGWhiz

Unless you have written code to override it, Ctl + P is the same as using
File>Print from the menu bar or ActiveSheet.PrintOut from code. In other
words, it uses the built in print command. There are no user developed print
procedures involved, and no alphabetic selection of workbooks. The print
command is at the application level, not the lower workbook level.
 
J

JLGWhiz

Another thought. Even if you have overridden the application print command
with a user developed macro, the keyboard shortcut will call whatever was
assigned to that shortcut when it was created, in the method defined by the
code that the procedure executes. So there is still no alphabetic selection
of workbooks. It selects what it is told to select by code.
 
T

Tim Williams

Try making a generic sub (which is the same in all workbooks) just to
capture the Ctrl+p and which then calls the "real" print macro in the
activeworkbook.

Sub PrintMeStarter()
Application.Run (ActiveWorkbook.Name & "!PrintMe")
End Sub

You'll have to handle catching an error if the active workbook doesn't have
a PrintMe() sub. Maybe just call the "regular" print in that case.

Tim.
 

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