Home > Software design >  Get the text on the (Shape) I just used to execute the macro
Get the text on the (Shape) I just used to execute the macro

Time:07-05

I have a simple code like below, then I assigned to a shape e.g. Rounded Rectangle1 with text inside it RunMe ,

Sub Caller_Text()
    MsgBox Application.Caller
End Sub

I need instead of the shape name to get the text on that shape I just used to execute the macro,

In advance, grateful for any useful comment and answer.

CodePudding user response:

Adapt this as required:

ButtonName = Application.Caller
Set MyShape = ActiveSheet.Shapes(ButtonName)
MyString = ActiveSheet.Shapes(MyShape.Name).TextFrame.Characters.Text
  • Related