ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Select Text in Text Box (https://www.excelbanter.com/excel-programming/281939-select-text-text-box.html)

Sam

Select Text in Text Box
 
Hello,

I have a user form that when it opens, I want the default text in it to be selected. I can't figure out how to do this. I've tried setting the relevant properties and used the Setfocus method, but I can't get it to work. Is this possible?

Any help would be appreciated!

Sam

Bob Phillips[_5_]

Select Text in Text Box
 
Sam,

You need SelStart as well

With TextBox1
.Text = "This is a test"
.SelStart = 0
.SelLength = Len(.Text)
.SetFocus
End With


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Thomas" wrote in message ...
Text1.SelLength = Len(Text1)

Sam wrote:

Hello,

I have a user form that when it opens, I want the default text in it to

be selected. I can't figure out how to do this. I've tried setting the
relevant properties and used the Setfocus method, but I can't get it to
work. Is this possible?

Any help would be appreciated!

Sam





All times are GMT +1. The time now is 10:57 PM.

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