obtaining the name of a button

  • Thread starter Thread starter jmoffat
  • Start date Start date
J

jmoffat

If you have assigned a macro to a shape - say a button from the form
bar - and you then activate the macro by clicking on the button, doe
anyone know the code to obtain the name of the button you clicked on ?

I think it should be along the lines of:

but_name = Activesheet.shapes.selection.name

but of course that doesn't work
 
Application.Caller will return the name of the shape that called
the macro. E.g.,

MsgBox Application.Caller


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


jmoffat said:
If you have assigned a macro to a shape - say a button from the forms
bar - and you then activate the macro by clicking on the button, does
anyone know the code to obtain the name of the button you clicked on ?

I think it should be along the lines of:

but_name = Activesheet.shapes.selection.name

but of course that doesn't work.


------------------------------------------------

~~View and post usenet messages directly from http://www.ExcelForum.com/

~~Now Available: Financial Statements.xls, a step by step guide
to creating financial statements
 
but_Name = Application.Caller

--
Regards,
Tom Ogilvy

jmoffat said:
If you have assigned a macro to a shape - say a button from the forms
bar - and you then activate the macro by clicking on the button, does
anyone know the code to obtain the name of the button you clicked on ?

I think it should be along the lines of:

but_name = Activesheet.shapes.selection.name

but of course that doesn't work.


------------------------------------------------



~~Now Available: Financial Statements.xls, a step by step guide to
creating financial statements
 
Back
Top