none
How to find document is newly created or existing file RRS feed

  • Question

  • Hello,

    I am creating new add in for Word using vsto add in (visual studio 2017).

    In which, i need few functionality, that if document is already created on my server then it should be over-written. and if not then custom pop should open and ask for location. (full functionality is as per word's save event,except location) 

    so for that i need :

    1. Need to find whether opened document is created using new template or its opened existing document.

    How can i get that ?

    Tuesday, September 11, 2018 11:30 AM

All replies

  • Hi DhrumilKothari,

    In order to find document is newly created or existing file, please try the code below:

    if (string.IsNullOrEmpty(WordInstance.ActiveDocument.Path))
       {
           throw new ApplicationException("Document must be saved first");
       }

    For more information, please review the following link:

    vsto - determine a word document if created from blank document or open from an existing document

    Hopefully it helps you. Looking forward to hearing from you.

    Best Regards,

    Yuki


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    Wednesday, September 12, 2018 5:31 AM
    Moderator
  • Hi DhrumilKothari,

    Thanks for your asking. Did you resolve your issue ? If the post helps you, you can mark it as answer and close the post.

    Thank you for understanding. If you have any question, or update, please feel free to let us know.

    I wish you a happy life!

    Best Regards,

    Yuki

    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    Tuesday, September 18, 2018 5:06 AM
    Moderator