Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default auto_close give me additional information?

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'
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default auto_close give me additional information?

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'

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default auto_close give me additional information?

Great! It's really my solution! Now i can improve my application.
Thanks!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,203
Default auto_close give me additional information?

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!

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default auto_close give me additional information?

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
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
How to get additional information rlo Excel Discussion (Misc queries) 4 September 25th 09 09:21 PM
Macro additional information LRay67 Excel Programming 1 March 12th 08 04:02 PM
Need your help. I need to add additional information into cells Shani Excel Programming 5 May 4th 06 06:56 PM
Bringing additional information in with combo box selection JD Excel Worksheet Functions 1 February 24th 05 01:45 AM
Repost for additional information Henry[_6_] Excel Programming 1 May 11th 04 03:35 AM


All times are GMT +1. The time now is 03:15 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"