[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


How to trap DocumentBeforeClose event in Word 2007 using C++ / ATL

Posted on 2007-10-03
Medium Priority
Last Modified: 2013-11-17
I am writting addin using Visual Studio 2005 C++ and ATL for Word 2007.  How do I get event notifications like    DocumentBeforeClose, DocumentBeforeSave, etc.   I need to do some processing before the document is closed or saved.  
Question by:cdoggett
  • 2
  • 2
LVL 12

Expert Comment

ID: 20011512
Writing application event procedures

Take Control of Microsoft Word Through Events

Intercepting events like Save and Print


Author Comment

ID: 20018466
Ya, I saw those myself...  Remember I am doing C++.

I added the IApplicationEvents2 interface but the events dont seem to get fired.
LVL 12

Accepted Solution

geneus earned 1000 total points
ID: 20021014
Maybe these resources will help you better.

HOW TO: Handle Word Events by Using Visual C++ .NET and MFC

Office Automation Using Visual C++

Microsoft Office Development with Visual Studio

Automation part 2

Supplementary Note: Automation and Remote Automation

Author Comment

ID: 20027780
Not trying to be a pain, however...  This is all stuff I have seen before.  Please don't send links to 'good stuff' if it doesn't address my exact problem.  I need how to implement a callback for the DocumentBeforeClose event in Visuall Studio 2005 using Word 2007.  This is important, I have it working just fine in Word 2003.  

I tried implementing the ApplicationEvents interface and it created the various Document events, but they are not being executed.


Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Currently, there is an issue with being able to copy values from an external application to a dropdown list in Project Web Access (PWA).  The standard copy and paste methods don't seem to work properly. Here is a way to accomplish this task to s…
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question