Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2005

Tip: Looking for answers? Try searching our database.

Textboxes in UserForms

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Roderick O'Regan - 04 Feb 2005 19:25 GMT
I have a userform with five textboxes. When the form initializes it
"reads" text located between bookmarks and places the various textual
items into their respective textboxes.

Is there a way, please, to show the contents of the first textbox
highlighted rather than the cursor being at the end of the text?

Naturally, when I press TAB to go to the next field the text is
highlighted.

A typical example of what I want to achieve is when one goes to
Tools|Options|User Information in Word and the Name field contents are
highlighted automatically.

Regards

Roderick
Doug Robbins - 04 Feb 2005 23:36 GMT
Have you tried using SetFocus on the field?

Signature

Please respond to the Newsgroup for the benefit of others who may be
interested.   Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP

>I have a userform with five textboxes. When the form initializes it
> "reads" text located between bookmarks and places the various textual
[quoted text clipped - 13 lines]
>
> Roderick
Roderick O'Regan - 05 Feb 2005 12:43 GMT
Thanks, Doug. Yes, I've tried it in the following way:
myfieldname.SetFocus but still with no luck - the cursor just goes to
the end of the words brought in from the bookmarked area.

Roderick

>Have you tried using SetFocus on the field?
Doug Robbins - 05 Feb 2005 13:10 GMT
This appears to do it:

TextBox1.SelStart = 0
TextBox1.SelLength = Len(TextBox1.Text)
TextBox1.SetFocus

Signature

Please respond to the Newsgroup for the benefit of others who may be
interested.   Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP

> Thanks, Doug. Yes, I've tried it in the following way:
> myfieldname.SetFocus but still with no luck - the cursor just goes to
[quoted text clipped - 3 lines]
>
>>Have you tried using SetFocus on the field?
Roderick O'Regan - 05 Feb 2005 23:38 GMT
It works! Thanks Doug.

When one reads what the code is saying it's blindingly obvious!

Regards

Roderick

>This appears to do it:
>
>TextBox1.SelStart = 0
>TextBox1.SelLength = Len(TextBox1.Text)
>TextBox1.SetFocus

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.