Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Hide/Show modeless userform when activating/deactivating workbooks

I''ve written the following code to make sure a modeless form hides if the
user activates another workbook while the form is showing. I'm posting to
see if there are better ways.

I dimension a public variable in a regular code module:
Public ShowUserForm1 As Boolean

In the ThisWorkbook object module I have:
-----------------------------------------------------------------------
Private Sub Workbook_Activate()
If ShowUserForm1 Then UserForm1.Show
End Sub

Private Sub Workbook_Deactivate()
If UserForm1.Visible = True Then
UserForm1.Hide
ShowUserForm1 = True
End If
End Sub
-----------------------------------------------------------------------


In the Terminate code of the Userform I have:
-----------------------------------------------------------------------
Private Sub UserForm_Terminate()
ShowUserForm1 = False
End Sub
-----------------------------------------------------------------------


This works great (as far as I've been able to test). Is there a better way?
Thanks!

-Jeremy


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
Userform, ComboBox, and Workbooks... Oh my!? fail2excel Excel Discussion (Misc queries) 3 July 31st 09 09:22 PM
Activating Workbooks Sungibungi Excel Discussion (Misc queries) 2 June 5th 09 04:22 AM
activating workbooks Ray Clark[_2_] Excel Discussion (Misc queries) 2 May 25th 09 04:25 AM
Modeless userform hngo New Users to Excel 2 July 13th 05 09:23 AM
hide a textbox on a userform? Bill Lunney Excel Programming 2 July 31st 03 08:57 AM


All times are GMT +1. The time now is 04:46 AM.

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

About Us

"It's about Microsoft Excel"