PC Review


Reply
Thread Tools Rate Thread

Closing Workbook then Activating Other Wb with Userform showing?

 
 
dimm
Guest
Posts: n/a
 
      24th Feb 2008
Hi all,

I have two workbooks - We'll call them Book1 & Book2.

When going into Book 2 I have a button on a userform in Bk1 which executes
the relevant code, part of which hides UserForm1 before opening Book2.

My problem is closing Book two and getting back into Book1 with the UserForm
opening automatically. At the moment I get around this by putting a button
onto a seperate sheet of Book 1 (Sheet1) which holds code to show my
UserForm, and it's clicked on by the user when Book1 opens, but surely there
a way to automatically go back to the userform?

My code from book 2 currently is:

Sub CloseWorkBook2()

Application.ScreenUpdating = False

Workbooks("Book2.xls").Activate
ActiveWorkbook.Save
ActiveWorkbook.Close

Workbooks("Book1.xls").Activate
Sheets("Sheet1").Select

ThisWorkbook.Save
ThisWorkbook.Close

Application.ScreenUpdating = True

End Sub

Any ideas are appreciated?

Thanks.

 
Reply With Quote
 
 
 
 
Nick Hodge
Guest
Posts: n/a
 
      24th Feb 2008
Dimm

You can put your code into the book 2 workbook_close() event. Then
automatically when you close the workbook it could open the book1 workbook
and then in the book1 Workbook_Open() event (or Workbook_Activate() if it is
already open) put a call to show the form (Theoretical code follows)

Private Sub Workbook_Open()
myForm1.Show
End Sub

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
(E-Mail Removed)DTHIS
web: www.excelusergroup.org
web: www.nickhodge.co.uk





"dimm" <(E-Mail Removed)> wrote in message
news:722B6BF1-5EC4-4747-858F-(E-Mail Removed)...
> Hi all,
>
> I have two workbooks - We'll call them Book1 & Book2.
>
> When going into Book 2 I have a button on a userform in Bk1 which executes
> the relevant code, part of which hides UserForm1 before opening Book2.
>
> My problem is closing Book two and getting back into Book1 with the
> UserForm
> opening automatically. At the moment I get around this by putting a button
> onto a seperate sheet of Book 1 (Sheet1) which holds code to show my
> UserForm, and it's clicked on by the user when Book1 opens, but surely
> there
> a way to automatically go back to the userform?
>
> My code from book 2 currently is:
>
> Sub CloseWorkBook2()
>
> Application.ScreenUpdating = False
>
> Workbooks("Book2.xls").Activate
> ActiveWorkbook.Save
> ActiveWorkbook.Close
>
> Workbooks("Book1.xls").Activate
> Sheets("Sheet1").Select
>
> ThisWorkbook.Save
> ThisWorkbook.Close
>
> Application.ScreenUpdating = True
>
> End Sub
>
> Any ideas are appreciated?
>
> Thanks.
>

 
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
loading, but not activating userform c1802362 Microsoft Excel Programming 1 11th Dec 2008 03:56 AM
Activating / Closing workbook using part name and a wild character =?Utf-8?B?c2hhcm1hbg==?= Microsoft Excel Programming 5 24th Jun 2005 04:00 PM
Activating userform and filling it with data form row where userform is activate Marthijn Beusekom via OfficeKB.com Microsoft Excel Programming 3 6th May 2005 05:44 PM
Excel VBA question - showing userform when opening workbook ajliaks Microsoft Excel Programming 2 12th Apr 2004 06:24 PM
showing a Userform from another workbook Todd Huttenstine Microsoft Excel Programming 1 26th Mar 2004 09:05 AM


Features
 

Advertising
 

Newsgroups
 


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