Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 281
  • Last Modified:

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

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
upobDaPlaya
Asked:
upobDaPlaya
3 Solutions
 
Frank WhiteCommented:
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
 
dlmilleCommented:
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
 
Rory ArchibaldCommented:
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
 
upobDaPlayaAuthor Commented:
Thanks EE gurus...I wish it was explained like the above in the online course I am taking...
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now