Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 150
Default Problems with Hiding/Showing Modeless Userforms

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Problems with Hiding/Showing Modeless Userforms

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)



"Raj" wrote in message
...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 150
Default Problems with Hiding/Showing Modeless Userforms

On Dec 17, 2:08 pm, "Bob Phillips" wrote:
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)

"Raj" wrote in message

...



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- Hide quoted text -


- Show quoted text -


Hi Bob,

Thanks. It worked.

Raj
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Two problems with userforms Derek Dowle Excel Programming 2 February 8th 06 02:00 PM
userforms showing and hiding Laurin[_11_] Excel Programming 4 December 20th 05 06:07 PM
problems with userforms [email protected] Excel Programming 2 April 2nd 05 06:53 AM
Hiding Userforms CeeKay Excel Programming 3 November 10th 04 01:53 AM
modeless userforms Don Cossitt Excel Programming 5 August 29th 03 08:39 PM


All times are GMT +1. The time now is 04:44 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"