(also posted to mrexcel.com and StackOverflow)
Why does programmatically closing a workbook break OnTime?
This code runs fine:
Manually close another workbook to fire oApp_WorkbookBeforeClose. MySub executes, as expected.
But, if instead of manually closing another book, you close another book programmatically, OnTime never runs. oApp_WorkbookBeforeClose does execute, so the OnTime is getting registered. But it never runs.
oApp_WorkbookBeforeClose runs. But MySub never runs.
Why doesn't OnTime execute if registered by programmatically closing a workbook? No code is running in the book that's closing. OnTime works no problem with other events (eg programmatically opening a workbook). Somehow, closing a workbook programmatically breaks OnTime.
Bookmarks