ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Highlight/Select contents of object with focus (https://www.excelbanter.com/excel-programming/287994-highlight-select-contents-object-focus.html)

andy[_5_]

Highlight/Select contents of object with focus
 
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

Chip Pearson

Highlight/Select contents of object with focus
 
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



"andy" wrote in message
...
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[_5_]

Highlight/Select contents of object with focus
 
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
-----Original Message-----
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



"andy" wrote in message
...
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



.



All times are GMT +1. The time now is 10:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com