I have a userform which I have had to make modeless so that I can access and use other excel workbooks while the form is active. Before changing it to modeless (i.e. it was initially the default modal) I could set the focus on a textbox and select the default text to highlight it. However, once I made it modeless the text is no longer highlighted.
I've searched the internet high and low and I cannot find a solution to this, even though the problem seems to have existed for 10 years or more! I even found a thread on this forum which asked the same question back in 2010, but again no solution, hence why I am asking again in case anyone has managed to find a solution since then.
The userform is called from a command button on the speadsheet, and the setfocus is done in the UserForm_Initialise event. This is the code:
With txtTextBox
.SetFocus
.SelStart = 0
.SelLength = Len(.Text)
End With
Like I said, this worked fine while the userform was modal, but it doesn't work when the userform is modeless. And again, I know this question has been asked many times on many forums, but I have yet to find a solution for it. Any help would be appreciated.
I've searched the internet high and low and I cannot find a solution to this, even though the problem seems to have existed for 10 years or more! I even found a thread on this forum which asked the same question back in 2010, but again no solution, hence why I am asking again in case anyone has managed to find a solution since then.
The userform is called from a command button on the speadsheet, and the setfocus is done in the UserForm_Initialise event. This is the code:
With txtTextBox
.SetFocus
.SelStart = 0
.SelLength = Len(.Text)
End With
Like I said, this worked fine while the userform was modal, but it doesn't work when the userform is modeless. And again, I know this question has been asked many times on many forums, but I have yet to find a solution for it. Any help would be appreciated.