Determining Caller of Event

J

Jack Bowling

Hello all,
I am trying to determine which button was pressed on a Worksheet. I have
10 buttons that use the same code. I need to know which button was pressed
so I don't need 10 copies of the same code. I am using the Click event for
the button. I have tried using Application.Caller to determine the button
but I get an error code instead of an object or name. I have tried using the
ME keyword but I get a reference to the worksheet not the button that the
event belongs too. Any suggestions would be appreciated.

Thanks
Jack
 
M

Mike Walker

Hi Jack

The only way I can think of getting around this is using a state public
variable that holds the current button name for reference and then call the
common code with this being looked at.

VBA doesn't support control indexes so you don't have a sender type argument
that will allow you to get the behaviour you are looking for,

Rgds

Mike Walker
(Reply via NG)
 
P

Pete Bennett

Try using

CommandBars.ActionControl

Which works in Word. Just use it in the function that's called from the
command bar button and that will return the control object for the button
that was pressed.
 

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