Identifying the button that activated the macro

C

Charlie

Is there a way tell tell what the .ID of the button was that started a macro?
I have several toolbar buttons running the same code, doing slightly
different things determined by their .ID
 
H

Helmut Weber

Hi Charlie,

I think that this is the question for:
"What code is being executed right now?"

I don't know of a way except
declaring in each macro a string with the name of that macro.

Then you can check, which button has
an onaction-property that equals the name of the macro.
Where the name, it seems, must include the module.

By the way, you can execute different code
for the same button by using the API-function "shiftstate".
So that "shift-button" would do something different
from "control-button" etc...

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
T

Tony Jollans

CommandBars.ActionControl

will give you a reference to the toolbar button, if that is how your nacro
was invoked. You can pick up it's ID or any other property from there,
 

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