Get active document template name RRS feed

  • Question

  • Hi All,

    We are working in a project where we develop Add-Ins for Word 2003, 2007 and 2010 including Word templates. I need to get the active Word Tempalte name or Active Document name in C++ code. Currently, we are hard-coding and giving a default template name which needs to replaced with any tempalte name.

    Below is the sample of what we are doing right now. Please let me know if I remove the first line of the code then what can replace it?

    static const TCHAR* CITECHECKTEMPLATE = _T("GEN.dotx");
    STDMETHODIMP CConnect::OnStartupComplete (SAFEARRAY ** /*custom*/ )
     HRESULT hr;
      // Look for our document template. If it's not there then we'll exit and assume
      // we were not installed correctly.
      CComBSTR ourTemplateName(CITECHECKTEMPLATE);
      CComPtr <Word::Templates> templates;

    Thanks, Atit Shah

    Monday, March 19, 2012 5:10 PM


  • It's done. Closing the thread! It's difficult to provide the code snippet here but in case anyone is facing the same issue, please let me know.

    Thanks, Atit Shah

    • Marked as answer by Atit Shah Tuesday, March 20, 2012 8:43 PM
    Tuesday, March 20, 2012 8:43 PM