Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

What is the difference btw before close event at the App Object level vs the Workbook object level

Posted on 2012-03-14
4
Medium Priority
?
276 Views
Last Modified: 2012-06-27
What is the difference between  the before close event at the Application Object level vs the the before close event at the Workbook object level.  I am taking an Excle class and I am puzzled on the distinction.
0
Comment
Question by:upobDaPlaya
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 3

Accepted Solution

by:
Frank White earned 668 total points
ID: 37723272
When you have a workbook open in Excel, the workbook may be closed without closing the application itself,  usually giving a blank page and the option to create a new workbook or open another one. In Excel 2000 through 2003, there are two separate "X" buttons in the top-right of the window. The one on the window's bar closes the program instance, while the smaller grey (by default) one inside the window will close only the active workbook.

So, if the event must run when that particular .xls file (that workbook) is closed, the before-close event at the workbook level should be used. If, however, you only want to do something when Excel altogether is closed, regardless of which files are open, closed, or even if none are open, then the Application Object level event is a better choice.

In practice, I rarely (if ever) use the application-level events, since my code is always within a module inside one of the excel files, and pertinent only for that workbook. Application-level events are usually coded through an add-in for more large-scale purposes where there might be hundreds of excel workbooks sharing similar functionality.
0
 
LVL 42

Assisted Solution

by:dlmille
dlmille earned 668 total points
ID: 37723309
My two cents:

The BeforeClose() event at the Workbook level is for that workbook.

The application level BeforeClose() event would trigger on any workbook close in that instance of Excel.
0
 
LVL 85

Assisted Solution

by:Rory Archibald
Rory Archibald earned 664 total points
ID: 37723891
NFP:

Dave is correct.The application-level event is application_workbookbeforeclose which fires for any workbook closing. There is in fact technically no event for the application itself closing, though of course the application_workbookbeforeclose will fire if you have an application-level event handler set up in a workbook or xla/xlam addin file.
0
 

Author Closing Comment

by:upobDaPlaya
ID: 37727693
Thanks EE gurus...I wish it was explained like the above in the online course I am taking...
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question