In Lesson 11, you learned about worksheet-level events and how they are triggered by actions relating to individual worksheets. Workbooks themselves can also recognize and respond to a number of events that take place at the workbook level. This lesson describes how you can further customize your workbooks with VBA procedures for the most commonly used workbook events.
Workbook events occur within a particular workbook. Many workbook events occur because something happened to an object in the workbook, such as a worksheet — any worksheet — that was activated, or a cell — any cell — that was changed. Other workbook events occur because the workbook was imposed upon to do something, such as to open or close, or to be saved or printed.
Unless the VBA code itself purposely refers to other workbooks, event procedures at the workbook level affect only the workbook within which the code resides.
You saw in Lesson 11 that each individual worksheet has its own module. Workbooks are similar to worksheets in this respect, because a workbook is also an Excel object, and has its own module already present and accounted for when the workbook is created.
Workbook-level event code always goes into the workbook module. You never need to create a workbook module or a worksheet module; Excel creates those modules automatically with every new workbook. If a workbook-level event ...