PC Review


Reply
Thread Tools Rate Thread

auto_close give me additional information?

 
 
SteAXA
Guest
Posts: n/a
 
      27th Apr 2010
Hi to everybody,
exists a way to know if i close only a workbook or the entire excel
application, when the users close the application by "X"? Exists anything
connected with auto_close that can take me that information?
I need this because when the user close a workbook or a application i need
to clean up an additional menu (that i've previously added for each workbook
opened by a macro) for the single workbook.
Thanks, Ste'
 
Reply With Quote
 
 
 
 
Jacob Skaria
Guest
Posts: n/a
 
      27th Apr 2010
Use the Workbook_BeforeClose event..

From workbook press Alt+F11 to launch VBE (Visual Basic Editor). From the
left treeview search for the workbook name and click on + to expand it.
Within that you should see the following

VBAProject(Your_Filename)
Microsoft Excel Objects
Sheet1(Sheet1)
Sheet2(Sheet2)
Sheet3(Sheet3)
This Workbook

Double click 'This WorkBook' and paste the below code to the right code pane.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
MsgBox "About to close"
End Sub


--
Jacob (MVP - Excel)


"SteAXA" wrote:

> Hi to everybody,
> exists a way to know if i close only a workbook or the entire excel
> application, when the users close the application by "X"? Exists anything
> connected with auto_close that can take me that information?
> I need this because when the user close a workbook or a application i need
> to clean up an additional menu (that i've previously added for each workbook
> opened by a macro) for the single workbook.
> Thanks, Ste'

 
Reply With Quote
 
SteAXA
Guest
Posts: n/a
 
      27th Apr 2010
Great! It's really my solution! Now i can improve my application.
Thanks!
 
Reply With Quote
 
JLatham
Guest
Posts: n/a
 
      27th Apr 2010
A couple of hints that may prove helpful to you with this also, since you're
working with custom menus.

When the workbook Opens, not only does its _Open() event fire, but so does
its _Activate() event. Likewise, when it is closed, both the _BeforeClose()
and _Deactivate() events fire off.

When working with custom menus in a workbook, I usually put my "create
custom menus" code into the Workbook_Activate() event code, and the "destroy
custom menus" code into the Workbook_Deactivate() event. This way, if a
person has multiple workbooks open, as they switch between them, they don't
have the (inappropriate) custom menu available in another workbook. But as
soon as they choose the book with the needed custom menu again, it will
reappear in that book -- which it wouldn't do if only controlled by _Open()
and _BeforeClose().

"SteAXA" wrote:

> Great! It's really my solution! Now i can improve my application.
> Thanks!

 
Reply With Quote
 
SteAXA
Guest
Posts: n/a
 
      28th Apr 2010
Thanks very much for your hints, now my application works more better!
I've used the workbook event for create and delete custum menus, and it's
more easy to manage.

 
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
How to get additional information rlo Microsoft Excel Misc 4 25th Sep 2009 09:21 PM
Could anyone please give brief information how could masani paresh Microsoft Outlook Calendar 0 31st Jul 2008 07:09 AM
Additional information =?Utf-8?B?U0hJUFA=?= Microsoft Access VBA Modules 0 25th Aug 2006 02:02 PM
Additional information =?Utf-8?B?RGFu?= Windows XP Internet Explorer 0 13th Sep 2005 05:45 PM
Additional Information Peaceworks Windows XP Help 0 2nd Jan 2005 09:30 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:35 AM.