Results 1 to 8 of 8
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [attachment=85954:WoodysAt...Template.jpg]

    we are in the process of upgrading from OfficeXP and Office 2007.

    We'll be running dual environments during the upgrade until everyone has been upgraded.

    The different versions of Word have different template directory locations

    Word XP has location
    C:\Program Files\Microsoft Office\Templates\Corrs

    The Word 2007 has different directory location
    C:\Program Files\CorrsOffice\

    When a Word 2007 document opens in Word XP, I need to capture the template name and full path.

    the screen capture displays the correct template path when I manually goto menu Tools, Template and -ins....

    The issue is I code to obtain template path, however as the 2007 template doesnt exist the code returns template path has "Normal.dot"


    Dim myTemplate As Template

    Set myTemplate = ActiveDocument.AttachedTemplate
    MsgBox myTemplate.Path & Application.PathSeparator & myTemplate.name



    anyone else come across this?
    got a workaround?

    diana
    Attached Images Attached Images

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,853
    Thanks
    4
    Thanked 259 Times in 239 Posts
    I am using Word 2007 on Vista and so I can't replicate the problem. The following suggestions may be pointless as it is conceivable that Word 2002 wont return the template name because it expects a dot filetype to be listed there.

    Is this only a problem when the template isn't found on that machine?

    You seem to have a lot of add-ins also running - if you disable all of them do you still get the same error?

    You can simplify your test by trying
    MsgBox ActiveDocument.AttachedTemplate.fullname
    If you test this then it might eliminate the object type of the variable as a possible issue.

    A left-field possibility is that you are stripping personal data from the saved files and this might also be wiping the template path. Have you investigated that.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. #3
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts
    the amount of template add-ins loaded has no effect

    ive tried...

    MsgBox ActiveDocument.AttachedTemplate.fullname

    and on a Word 2007 document generated from Word 2007 template
    it returns "Normal.dot"

    so maybe a limitation, if the template file doesnt exist just then return "normal.dot" *shrug* im not sure

    diana

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Word 2002 acts exactly the same way - if a document is attached to a template that no longer exists, the dialog in the interface still displays the old path and filename of the template, but VBA reports Normal.dot.

    The workaround is to recreate the folder C:\Program Files\Microsoft Office\Templates\Corrs with the Word 2002 templates on the PCs with Office 2007.

  5. #5
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,853
    Thanks
    4
    Thanked 259 Times in 239 Posts
    What do you get if you try
    MsgBox Dialogs(wdDialogToolsTemplates).Template
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  6. #6
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='Diana' post='797802' date='13-Oct-2009 22:27']The different versions of Word have different template directory locations ... got a workaround?[/quote]
    Diana, people are using my Setup078.dot to install word templates as addins on a wide variety of installations around the world.
    The code within Setup has to unhook any existing addins, rename stale versions and move in newer versions of templates for whatever version of OS/Office the user is running.
    You could email me (from www.ChrisGreaves.com) to get a zipped copy by reply mail, or go to one of my downloads sites (e.g. www.indxr.ca) and d/l the zip and take a look for yourself.

    My MRUse utility takes the time to explore all possible versions of MSoffice applications to locate things like recently-used lists; that too might have a clue coming from the registry direction.

  7. #7
    2 Star Lounger
    Join Date
    May 2006
    Location
    Currently in Europe
    Posts
    103
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Diana:

    I don't know if you're still waiting for a solution - I found your question today, 10 days after you posted it. I'll contribute my two bits worth below.

    I had something like the same problem a couple of years ago, when an office share drive (containing templates) was arbitrarily banished by management. I had to remap all sorts of stuff. An ugly experience. In that process I had to discover the following:


    Dim strDocTemplateString As String
    Dim strWordTemplate As String
    Dim strCurrentPath As String

    ' Complete path of the Active Document's original template - meta information contained in the Word file
    strDocTemplateString = Application.Dialogs(87).Template

    ' Word's idea of attached template - the template actually attached at the moment
    strCurrentPath = Word.Options.DefaultFilePath(wdWorkgroupTemplatesP ath)

    ' Current path of the Word Workgroup Templates
    strWordTemplate = ActiveDocument.AttachedTemplate

    I hope this helps!
    Stylus

  8. #8
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thank you all

    I have a working solution.

    The code I wrote was a bit long winded, and I was hoping for a cleaner simpler solution.

    But I got it working in the end


    many thanks again...

    diana

Posting Permissions

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