excelvbaactivexobject

Excel VBA to select text in ActiveX Text Box


I am trying to write a macro in Excel VBA that selects the text in a ActiveX Text Box, so I can later on manipulate it via the keyboard.

I want a command that would work similarly to the following:

ActiveSheet.Shapes("Shape Name").TextFrame2.TextRange.Select

However, the code reference required is OLEObjects since I am using an ActiveX Text Box...

I know I can change the text with a makro using something like:

ActiveSheet.OLEObjects("Shape Name").Object.Text = "Text"

But I do not want to use the macro to change the text, I simply want to select it so I can type into it with my keyboard next.

Thanks for your help!


Solution

  • Try this:

    ActiveSheet.OLEObjects("Shape Name").Activate