locked
Determine the location of the template RRS feed

  • Question

  • Hi,

    I have started to create an add-in that will interact with a SharePoint list when the a new document is created from a SharePoint document library. The add-in is created and reacts on the NewDocument event, but I can not find any property on the Word application object (or in ActiveDocument) that tells me from which location the template was loaded/started.

    What I want to know is: Which document library have the user used for creating this new document?

    Regards,

    // Henrik

    Tuesday, January 9, 2007 2:47 PM

Answers

  • Hi Henrik

    Note that most people here have no experience or special knowledge concerning SharePoint. You may need to ask in a SharePoint newsgroup if the information I give you isn't appropriate to your scenario.

    To query the file path for the template from which a document was created:

       ActiveDocument.AttachedTemplate.Path

    (where ActiveDocument can be any document object. If you're using C#, you probably need to use get_AttachedTemplate to assign to a field of type Template, then use the Path property with that.)

    Tuesday, January 9, 2007 3:23 PM
  • Hi Henrik

    Just renaming a file from doc to dot won't turn it into a real template. A template contains structures a document does not. To create a template from an existing document it must be opened in Word, then saved specifically as the File Type Word Template (*.dot).

    Wednesday, January 10, 2007 8:21 AM

All replies

  • Hi Henrik

    Note that most people here have no experience or special knowledge concerning SharePoint. You may need to ask in a SharePoint newsgroup if the information I give you isn't appropriate to your scenario.

    To query the file path for the template from which a document was created:

       ActiveDocument.AttachedTemplate.Path

    (where ActiveDocument can be any document object. If you're using C#, you probably need to use get_AttachedTemplate to assign to a field of type Template, then use the Path property with that.)

    Tuesday, January 9, 2007 3:23 PM
  • Hi Cindy,

    Thanks for the prompt answer.

    >Note that most people here have no experience or special knowledge concerning SharePoint. You may need to ask in a SharePoint newsgroup if the information I give you isn't appropriate to your scenario.
    ok, I understand. Hopefully this is a Word/VSTO issue anyway and Word just consider SharePoint as an standard folder.

    If I use the method get_AttachedTemplate, one template is returned (normal.dot). Is there any other collection which might contain this information?

    Regards,

    // Henrik

    Tuesday, January 9, 2007 4:14 PM
  • Hi Henrik

    I can only speak from the Word side of things, here. So you I think you will need to pursue this in a Sharepoint venue, to find out how the "internals" of what you're doing works...

    If the Word document you're using get_AttachedTemplate is one that came from Sharepoint, then I'd say it wasn't created from a true Word template (*.dot). Is it possible that a document is being called "a template", but isn't a true WORD template? And that this document that's acting as a template (a copy is being created from it) was originally created from Normal.dot?

    If that is the case, I'm not sure you can get the place from which it originated. But, as I say, a Sharepoint group would be the place to ask...

    Tuesday, January 9, 2007 5:04 PM
  • Hi again,

    I renamed the template file from .doc to .dot in the sharepoint library but I still don´t get the template path. I´ll start a new thread in a SharePoint group with a reference to this thread.

    Thanks for your time and effort.

    // Henrik

    Wednesday, January 10, 2007 7:26 AM
  • Hi Henrik

    Just renaming a file from doc to dot won't turn it into a real template. A template contains structures a document does not. To create a template from an existing document it must be opened in Word, then saved specifically as the File Type Word Template (*.dot).

    Wednesday, January 10, 2007 8:21 AM
  • yes! That did the trick, now I get the template path and fullname in the "New document" event!

    Many thanks for this help, it was great

    // Henrik

    Wednesday, January 10, 2007 8:33 AM