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
223 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
4 Comments
 
LVL 3

Accepted Solution

by:
DaFranker earned 167 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 41

Assisted Solution

by:dlmille
dlmille earned 167 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 166 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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,…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now