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
267 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:
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 42

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
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.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

739 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