Problems with Hiding/Showing Modeless Userforms

R

Raj

I have a modeless useform. When the user switches to another workbook,
the userform has to be hidden, and, when the user switches back to the
workbook, the userform should be shown again. Everytime the userform
is shown, the cursor/insertion pointer should appear in textbox1.

The following code is used:
--For displaying the cursor/insertion pointer in textbox1
Private Sub UserForm_Activate()
With UserForm1
.Top = Application.Top + 200 '< change 125 to what u want
.Left = Application.Left + 635 '< change 25 to what u want
End With
UserForm1.TextBox1.SetFocus
UserForm1.TextBox1.Text = ""
End Sub

--For Hiding the userform when the workbook is deactivated:
Private Sub Workbook_Deactivate()
UserForm1.Hide
End Sub
--For showing the userform when the workbook is activated:
Private Sub Workbook_Activate()
UserForm1.Show
End Sub

Everything works as expected except that the cursor/insertion pointer
is not appearing in textbox1. What should I do to achieve this?

Thanks in advance for all the help.

Regards,
Raj
 
B

Bob Phillips

Try setting the focus to another control, then set it to the textbox.

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
R

Raj

Try setting the focus to another control, then set it to the textbox.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)











- Show quoted text -

Hi Bob,

Thanks. It worked.

Raj
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top