Results 1 to 2 of 2
  1. #1
    New Lounger
    Join Date
    Apr 2001
    Middlesex, UK
    Thanked 0 Times in 0 Posts

    Getting the full template path (2000 SR1a)

    I have an old Word Basic macro that extracts the name and path of the template that was used to create the document. I tried to rewrite this macro in VBA (Word2000 SR1a) without relying on the WordBasic object and hit some interesting problems.

    The name and path of the template that was used to create a document are stored in the new document. You can see the information on paper by printing Document Properties from the File|Print dialog. The information is also visible in the File|Document Statistics dialog.

    The appropriate VBA construction to get this information seemed to be: ActiveDocument.BuiltInDocumentProperties(wdPropert yTemplate), but this returns only the template name with no path. I then tried ActiveDocument.AttachedTemplate.Path. This does return the full path, but there is also a snag. If Word finds a template in the Workgroup Templates location that has the same name as that used to create the document (which might have been in the User Templates location), then that is the path and file that are returned. (Annoying behaviour in itself, giving problems with Autotext entries and styles. I admit I have local templates that have the same name as - and of course are better than - those on the network location!).

    In the end I have had to use a reference to the FileSummaryInfo dialog, which works perfectly:
    Set dlg = Dialogs(wdDialogFileSummaryInfo)
    Template$ = dlg.Template

    File Summary Info is a left over from older versions of Word (and now called Properties), but it does return the full correct template path. However, I'm concerned that this functionality may disappear from future versions of Word, and it doesn't seem very elegant to refer to the dialogs collection. I think it's quite slow, too.

    I wondered if anyone else had come across this and figured out their own work-around? I could find nothing on the MS Knowledge Base.

  2. #2
    Super Moderator
    Join Date
    Dec 2000
    New York, NY
    Thanked 29 Times in 27 Posts

    Re: Getting the full template path (2000 SR1a)


    Here's another approach, similar to what you are doing.
    It should be quicker though:

    Public Sub GetTemplPath()
    Dim strOrigTemplatePath As String
    With Dialogs(wdDialogToolsTemplates)
    strOrigTemplatePath = .Template
    End With
    MsgBox strOrigTemplatePath
    End Sub

    This isn't necessarily going to return the path of the template that was first used to create the document; rather it returns the path of the template that is currently attached (which doesn't necessarily mean that it exists anymore either!).
    Anyway, this method is usually good enough.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts