Article ID: 166144
Article Last Modified on 9/13/2006
Sub ActivateTextBox()
'Dimension variables.
Dim xString As String
'In this example, the name of the text box is "Text Box 1". You
'can change this as required.
ActiveSheet.TextBoxes("Text Box 1").Select
'Store the contents of the text box in the variable xString.
If Len(Selection.Text) > 0 Then
xString = Selection.Text
Else
xString = ""
End If
'Use SendKeys to activate the text box, restore the original text,
'and move to the beginning of the text box.
Application.SendKeys (xString & "^{HOME}")
End Sub
When you run this macro, "Text Box 1" will be activated for editing. The
contents of the text box will not be removed, but they will be re-entered
by the macro, so you may see the contents briefly disappear and then
reappear. If the text box contains a large amount of text, it may take
several seconds or more for the text to reappear.
Additional query words: XL7 XL5
Keywords: kbinfo kbprogramming kbcode KB166144