View Single Post
 
Old 05-03-2017, 01:19 PM
skarden skarden is offline Windows Vista Office 2010 64bit
Novice
 
Join Date: Dec 2011
Location: Orlando, FL
Posts: 26
skarden is on a distinguished road
Question How to dectect if close document and now no document open

I have buttons on the ribbon of my Word add-in template that I want to disable if there is no document open in Word. I know how to create an application level class and/or a document class. However, while the document class has a Close event, it fires before the document actually closes.

In the application class they have a BeforeClose, which, as expected, (also) fires before the document closes. They also have WindowActivate and WindowDeactivate events, but if I just close the only open document, so I now have a blank screen in Word, that doesn't fire either the WindowActivate or WindowDeactivate events.

I'm using the Application BeforeClose and testing If Documents.Count = 1 ... (as the document is about to close, so the Application Count should be going to zero) but that is a kludge.

Is there any event to test AfterClose (since, again, the Document class Close fires before the document actually closes.)?

Thanks,

Stuart
Reply With Quote