Highlight/Select contents of object with focus

  • Thread starter Thread starter andy
  • Start date Start date
A

andy

I appoligize for the cross post from General, however no
one answered my post yesterday.

Some very nice people in this newsgroup gave me the code
to be able to tab, or sift/tab (move) between objects on
an Exel page.

Could someone tell me, once I have tabbed to the object
and it has the focus (e.g. textbox1.activate) how, if
there is text in the object, to hightlight/select all the
text. This is the normal behaviour in MS apps. In this way
the user can either tab through to the next, or return to
the previous, and since the text is highlighted/selected
if the user starts typing, the original text is replaced
with what the user is typing, without the user haveing to
either hightlight/select the original text with the mouse,
or extra keystrokes.

Thank you in advance
God bless you
 
Andy,

Try something like the following:

Private Sub TextBox1_GotFocus()
With Me.TextBox1
.SelStart = 0
.SelLength = Len(.Text)
End With
End Sub


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

I thank God you knew the answer. Your solution finished
this project. Thank you for being willing to share your
expertise.

God bless you
 
Back
Top