PC Review


Reply
Thread Tools Rate Thread

Call user form from ThisWorkbook; close file if form closed

 
 
=?Utf-8?B?WFA=?=
Guest
Posts: n/a
 
      20th Jul 2007
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 With Quote
 
 
 
 
=?Utf-8?B?QW5vbnk=?=
Guest
Posts: n/a
 
      20th Jul 2007
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
 
Reply With Quote
 
RB Smissaert
Guest
Posts: n/a
 
      20th Jul 2007
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" <(E-Mail Removed)> wrote in message
news:8F904B5B-ECE1-4665-83AE-(E-Mail Removed)...
> 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Form.Closing event not fired always when i call Form.Close method berylwilson Microsoft Dot NET Framework Forms 1 20th Apr 2007 02:11 AM
Close form then Delete form = Error as "Not Closed' =?Utf-8?B?Q2FuIE9mIFdvcm1z?= Microsoft Access Form Coding 1 21st Feb 2007 10:03 PM
Excel is Ignoring ThisWorkbook.Save event after Thisworkbook.Close call John Fuller Microsoft Excel Programming 5 30th Aug 2006 09:57 PM
Call data collection form from Function and wait till form close t =?Utf-8?B?ZGtlcm4=?= Microsoft Access 1 27th Feb 2006 03:36 AM
close child form when parent form is closed. =?Utf-8?B?UGF1bA==?= Microsoft ASP .NET 2 24th Nov 2004 10:31 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:10 PM.