VSTO Add-in which creates document based on the selected template RRS feed

  • Question

  • I want to use an Word-AddIn to create a new document  based on an existing template.... on the button click from the add-in ribbon - what command do I issue? 

    if I simply open the document, it doesn't fire the code I need on document_new in the document customization

    I found this Note on a forum:

    Note   Double-clicking the template file will open a new document that is based on the template, and not the template itself, which is useful for testing purposes but to make changes to a template itself

    How do I mimic that in code?

    Wednesday, June 23, 2010 6:25 PM


  • Hello Jocrews,

    If you just want to create a new document based on a template, please use following code:

    Documents.Add Template:= _
            "C:\Users\abc\AppData\Roaming\Microsoft\Templates\NormalEmail.dotm", _
            NewTemplate:=False, DocumentType:=0

    Above code is written in VBA if you have any problem to convert it to C#/VB.Net please feel free to follow up.


    Tim Li

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by jocrews Thursday, June 24, 2010 1:13 PM
    Thursday, June 24, 2010 7:17 AM