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
244 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

813 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

14 Experts available now in Live!

Get 1:1 Help Now