none
How to disable prompt for changes to doc template when closing Word 2010. RRS feed

  • Question

  • Hi,

    I get prompt for changes to doc template when closing Word 2010 after simultaneously opening multiple documents. This prompt does not appear if MyPlugin is disabled or uninstalled.

    This occurs only in some machines, and all other machines it is working fine.

    Steps to recreate the issue

    1. go to My Documents
    2. Highlight 2 or more docs
    3. Press enter or right click & open
    4. begin closing opened docs (in any order)
    *at some point here i am seeing a prompt to save changes to the document template.

    The issue occurs in machine has Win XP with Office 2010.

    Please let me know Why i am facing this issue, what may be the root cause of the issue and how can i stop the message popping up.

    Thanks in advance.

    Regards, Chetan.


    Chetan Rajakumar

    Wednesday, November 21, 2012 2:21 PM

Answers

  • Hi Cindy,

    Thanks for Reply.

    My Addin extracts all the text in document, do some processing, highlight some text in document. It is a COM Addin.

    I am able to solve this issue with the below code:

    /*CComPtr<Word::_Document> pDoc;
     CComVariant pTemp;
     m_pWordApp->get_ActiveDocument(&pDoc);
     pDoc->get_AttachedTemplate(&pTemp);
     pTemp.ppdispVal;*/
     CComBSTR ourTemplateName(MYTEMPLATE);
     CComPtr <Word::Templates> templates;
     CComPtr <Word::Template> eachtemplate;
     m_pWordApp->get_Templates(&templates);

     long numTemplates;
     templates->get_Count(&numTemplates);
     for (long i=1; i<=numTemplates; i++)
     {
      CComVariant index(i);
      templates->Item(&index, &eachtemplate);
      CComBSTR name;
      eachtemplate->get_Name(&name);
      if(name == ourTemplateName)
      {
       eachtemplate->put_Saved(TRUE);
      }

       
     }

    I am saving the template in DocumentBeforeClose event so that i won't get prompt for saving the changes.

    Thanks and Regards,Chetan.


    Chetan Rajakumar

    Monday, November 26, 2012 7:32 AM

All replies

  • Hi Chetan

    Only someone who has your addin installed will be able to follow the steps and reliably reproduce the behavior.

    What, exactly, does your MyPlugin do while it's loaded? What events does it monitor?

    What kind of add-in is MyPlugin? A VSTO add-in? An IDTExtensibility2 COM Add-in? A VBA add-in? Something else?

    Is this happening with different templates or one specific template? Does the template contain any macros?


    Cindy Meister, VSTO/Word MVP, my blog

    Wednesday, November 21, 2012 3:15 PM
    Moderator
  • Hi Cindy,

    Thanks for Reply.

    My Addin extracts all the text in document, do some processing, highlight some text in document. It is a COM Addin.

    I am able to solve this issue with the below code:

    /*CComPtr<Word::_Document> pDoc;
     CComVariant pTemp;
     m_pWordApp->get_ActiveDocument(&pDoc);
     pDoc->get_AttachedTemplate(&pTemp);
     pTemp.ppdispVal;*/
     CComBSTR ourTemplateName(MYTEMPLATE);
     CComPtr <Word::Templates> templates;
     CComPtr <Word::Template> eachtemplate;
     m_pWordApp->get_Templates(&templates);

     long numTemplates;
     templates->get_Count(&numTemplates);
     for (long i=1; i<=numTemplates; i++)
     {
      CComVariant index(i);
      templates->Item(&index, &eachtemplate);
      CComBSTR name;
      eachtemplate->get_Name(&name);
      if(name == ourTemplateName)
      {
       eachtemplate->put_Saved(TRUE);
      }

       
     }

    I am saving the template in DocumentBeforeClose event so that i won't get prompt for saving the changes.

    Thanks and Regards,Chetan.


    Chetan Rajakumar

    Monday, November 26, 2012 7:32 AM