View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JLGWhiz JLGWhiz is offline
external usenet poster
 
Posts: 3,986
Default How to force selection of all current text in textbox control on e

Try putting it in the initialize evert. I used this code and it worked.

Private Sub UserForm_Initialize()
TextBox1.MultiLine = True
TextBox1.EnterFieldBehavior = _
fmEnterFieldBehaviorRecallSelection
TextBox1.Text = "Type your text here. " _
& "Use CTRL+ENTER to start a new line."
Me.TextBox1.SelStart = 0
Me.TextBox1.SelLength = Len(Me.TextBox1)
End Sub

"Chrisso" wrote:

Hi All

I have a text box on a form. When the user selects the text box it is
*always* to completely change the value. Therefore I would like to
program an event that selects all the current text in the text box
when the user selects it - that way they are ready immediately to
begin typing the new value.

Hoever I cannot get this to work:

Private Sub txtCanvasSizeWidth_Enter()
Me.txtCanvasSizeWidth.SelStart = 0
Me.txtCanvasSizeWidth.SelLength = Len(Me.txtCanvasSizeWidth)
End Sub

Can anyone help? Thanks in advance for any ideas?

Chrisso