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

Posted on 2007-10-03
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
    LVL 12

    Expert Comment

    Writing application event procedures

    Take Control of Microsoft Word Through Events

    Intercepting events like Save and Print


    Author Comment

    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

    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

    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.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
    This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
    Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…
    This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now