Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8630931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:08:43+00:00 2026-06-12T09:08:43+00:00

Neither the NewDocument nor the DocumentOpen event is fired when Microsoft Word first loads.

  • 0

Neither the NewDocument nor the DocumentOpen event is fired when Microsoft Word first loads. When an instance of Word is already open and a new or existing document is opened then these events fire fine.

The suggestion I’ve seen is to handle the DocumentChange event (which is always fired when Word loads) instead of the other two events.

My question is how would I go about this? The DocumentChange event does not have any parameters so how would I know when the document (new or existing) was just opened?

Additionally, I already have logic in the DocumentChange event and the processing for new and existing documents is different so I can’t just throw all of my code into the event.

private void ThisAddIn_Startup(object sender, System.EventArgs a)
{
  this.Application.DocumentChange += new ApplicationEvents4_DocumentChangeEventHandler(Application_DocumentChange);
}

private void Application_DocumentChange()
{
  // How do I handle NewDocument or DocumentOpen?
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T09:08:44+00:00Added an answer on June 12, 2026 at 9:08 am

    So I ended up processing the loaded document in ThisAddIn_Startup. If the Path of the document is an empty string, then we know that the document is new and has never been saved on the local machine. Else, I know it is saved (including in the temp directory) and I process it as an existing document.

    private void ThisAddIn_Startup(object sender, System.EventArgs a)
    {
      try
      {
        Word.Document doc = this.Application.ActiveDocument;
        if (String.IsNullOrWhiteSpace(doc.Path))
        {
          ProcessNewDocument(doc);
        }
        else
        {
          ProcessDocumentOpen(doc);
        }
      }
      catch (COMException e)
      {
        log.Debug("No document loaded with word.");
      }
    
      // These can be set anywhere in the method, because they are not fired for documents loaded when Word is initialized.
      ((MSWord.ApplicationEvents4_Event)this.Application).NewDocument +=
        new MSWord.ApplicationEvents4_NewDocumentEventHandler(Application_NewDocument);
      this.Application.DocumentOpen +=
        new MSWord.ApplicationEvents4_DocumentOpenEventHandler(Application_DocumentOpen);
    }
    

    As my comment for Deni’s answer states:
    Setting the DocumentOpen event handler in ThisAddIn.Desiger.cs’s Initialize() method worked for existing documents, but NewDocument is not called for a new document initialized when Word opens, so this solution did not work. So I left the setting of DocumentOpen and NewDocument in the ThisAddIn_Startup event, else DocumentOpen will be fired when a document loads with Word as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Neither I could find a tutorial-like scheme for a resize event on QMainWindow, nor
It opens neither a tab nor a window: the code for a Google Gadget
It's neither 0x nor 0 ; what is it? Is there?
I've a normal Java class (neither a JSP nor a Servlet) that performs some
According to php manual nor php://input neither $HTTP_RAW_POST_DATA work with multipart/form-data POST-requests. php://input allows
I'm having a bit of a problem because neither Javascript nor ActiveX (written in
I'm trying to create a somewhat complex sorting feature which neither uses divs nor
I was asked to implement a menu bar that is neither horizontal nor vertical.
Neither the <blink> tag nor the text-decoration:blink; style in css are supported in Internet
Apparently neither instanceof nor typeof deliver in terms of correctly identifying the type of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.