Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
XP XP is offline
external usenet poster
 
Posts: 389
Default Call user form from ThisWorkbook; close file if form closed

Using Office 2003 and Windows XP;

1. Could someone please post an example of a command that could call a sub
in a user Form module from the ThisWorkBook module?

For example:

In THISWORKBOOK:

Private Sub Workbook_Open()
Call UserForm_Initialize
End Sub

In FORM MODULE:

Public Sub UserForm_Initialize()
<other code here
Me.Show
End Sub

2. Is it possible to code a workbook to close automatically if the user form
is closed? If so, how?

Many thanks for your assistance.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Call user form from ThisWorkbook; close file if form closed

PART 1.
Here are some examples:

In ThisWorkbook:
Private Sub Workbook_Open()
UserForm1.Show 'Or whatever your userform is named
End Sub

---------------------------
In form module:
Private Sub UserForm_Initialize()
Call Main 'This would be the module with your code in it
End Sub


PART 2.
Copy and paste this into the form module:

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
ThisWorkbook.Close (True) 'This saves all changes and closes the workbook
End Sub
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Call user form from ThisWorkbook; close file if form closed

In ThisWorkbook module:

Private Sub ThisWorkbook_Open()
Load Userform1
Userform1.Show
End Sub


In the form module:

Private Sub UserForm1_Terminate()
ActiveWorkbook.Close False
End Sub


RBS


"XP" wrote in message
...
Using Office 2003 and Windows XP;

1. Could someone please post an example of a command that could call a sub
in a user Form module from the ThisWorkBook module?

For example:

In THISWORKBOOK:

Private Sub Workbook_Open()
Call UserForm_Initialize
End Sub

In FORM MODULE:

Public Sub UserForm_Initialize()
<other code here
Me.Show
End Sub

2. Is it possible to code a workbook to close automatically if the user
form
is closed? If so, how?

Many thanks for your assistance.


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
Close User Form Gazz_85[_2_] Excel Discussion (Misc queries) 1 July 8th 09 10:38 AM
close user form ViestaWu Excel Programming 5 July 14th 06 02:53 PM
Open Only the User Form ... or Close Everything ! monir Excel Programming 4 April 2nd 06 09:30 PM
Button to call a user form? Hru48[_3_] Excel Programming 3 September 1st 05 06:22 PM


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

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"