![]() |
|
![]() |
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
![]()
Let's say I can create a document from a template ("C:\some\arbitrary\path\mytemplate.dotm", for the sake of argument). How can I programmatically get the full path of the template from which the document was created?
|
#2
|
||||
|
||||
![]()
In the VBA window, click "Tools" and then "References...". Ensure that the checkbox next to the template in question is checked. To get the path of this template, use the following code:
Code:
mytemplate.ThisDocument.Path |
#3
|
||||
|
||||
![]()
The VBA code for retrieving the active document's template path is:
ActiveDocument.AttachedTemplate.Path
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#4
|
|||
|
|||
![]()
Hello,
I'm trying to use Document_New() at the time of creating a new document based on a template, to determine the template's path and use a portion of that path to automatically save the new document. For example, using the path from the original question (C:\some\arbitrary\path\mytemplate.dotm) I would save the new document to C:\some\arbitrary\path\another\newdocument.docx When I query ActiveDocument.AttachedTemplate.Path it gives me "C:\Users\Lizzie\AppData\Roaming\Microsoft\Templat es" however, this is not where my template is saved. In Word I have changed the "Default personal templates location" in File/Options/Save to the new path. |
#5
|
|||
|
|||
![]()
I found the problem... I had saved my template as a ".docm" rather than a ".dotm". Once I corrected this, ActiveDocument.AttachedTemplate.Path worked like a charm!!
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Document Filename Generator for Referencing | john.adams | Word | 10 | 03-26-2013 12:14 AM |
![]() |
Knawl | Word | 11 | 10-10-2011 03:00 AM |
![]() |
MYGS | Word | 14 | 06-02-2011 09:44 PM |
Macro to determine attached template | zippyaus | Word VBA | 0 | 03-02-2010 02:05 AM |
Word: The document 'Filename' caused a serious error the last time ... | martincruise | Word | 0 | 02-25-2010 01:47 AM |