Greg Truby
MrExcel MVP
- Joined
- Jun 19, 2002
- Messages
- 10,025
By the time I started using a lot of VBA, the Autpen() and Auto_Close() methods' use was waning, supplanted by the _Open() and _BeforeClose() event handlers for the workbook object. So I never really got into the habit of using them.
However, I've been reading Bullen, Bovey & Green's book Professional Excel Development<SUP>1</SUP> and they use Autpen() quite a bit. So I've been plinkin' around a bit trying to suss out the differences. Do I have this more or less correct?
If I put in both an Autpen() in a standard module and a Workbook_Open()in the WB's code module both execute. But if I were to have Application.EventsEnabled set to FALSE; the Autpen() still executes upon opening the workbook whereas the Workbook_Open() will not?<sup>2</sup> And that since the open event handler runs before the Autpen() subroutine, using the Autpen() to insure that events are enabled does not cause the WB_Open() event handler to fire.
Auto_Close() runs even if EnableEvent = FALSE and (of course) WB_BeforeClose(...) does not fire. HOWEVER, just to make things interesting: if EnableEvents = TRUE and I hold down the SHIFT key while opening, neither of the open procedures fires. Whereas if I hold don the SHIFT key when closing, the _BeforeClose() event still gets raised; but the Auto_Close() does not run.
Does that about sum up the differences? Or are there more differences that I should be aware of?
<HR>
1. If you have developed a few complex projects and more-or-less can run back through Walkenbach's PowerProgramming with VBA book without seeing too much that you've forgotten; then this is the book to take you to the next level.
2. Both scenarios assume that macros are enabled.
However, I've been reading Bullen, Bovey & Green's book Professional Excel Development<SUP>1</SUP> and they use Autpen() quite a bit. So I've been plinkin' around a bit trying to suss out the differences. Do I have this more or less correct?
If I put in both an Autpen() in a standard module and a Workbook_Open()in the WB's code module both execute. But if I were to have Application.EventsEnabled set to FALSE; the Autpen() still executes upon opening the workbook whereas the Workbook_Open() will not?<sup>2</sup> And that since the open event handler runs before the Autpen() subroutine, using the Autpen() to insure that events are enabled does not cause the WB_Open() event handler to fire.
Auto_Close() runs even if EnableEvent = FALSE and (of course) WB_BeforeClose(...) does not fire. HOWEVER, just to make things interesting: if EnableEvents = TRUE and I hold down the SHIFT key while opening, neither of the open procedures fires. Whereas if I hold don the SHIFT key when closing, the _BeforeClose() event still gets raised; but the Auto_Close() does not run.
Does that about sum up the differences? Or are there more differences that I should be aware of?
<HR>
1. If you have developed a few complex projects and more-or-less can run back through Walkenbach's PowerProgramming with VBA book without seeing too much that you've forgotten; then this is the book to take you to the next level.
2. Both scenarios assume that macros are enabled.
Last edited: