Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Jun 2001
    Location
    York, Pennsylvania, USA
    Posts
    164
    Thanks
    0
    Thanked 3 Times in 2 Posts
    Folks,

    I've got a VBA program where we've got around 1000 Word 2003 'boilerplate' documents that are used as a master document for Word merges, then saved elsewhere so that the original stays 'original'.

    Since these documents are maintained by others, in my VBA code I've got a check to ensure that the attached template is the template with the code in it so that styles, etc. are consistent.

    We're in the process of upgrading to Word2007 and I find that the code used to chack the attached template name is not returning the correct attached template.

    This code:

    strTemp = ActiveDocument.AttachedTemplate.Name

    in Word2003 returns the template attached to the document.

    In Word2007, it returns 'normal.dotm'.

    The document is being opened from the network in read only mode:

    Documents.Open FileName:=strTemp, ReadOnly:=True
    Documents(strTemp).Activate

    I can manually open the same document (it opens in compatability mode) and see the template that's attached is the correct one.

    Any thought?

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts
    [quote name='mdenison' post='763577' date='05-Mar-2009 05:49']I can manually open the same document (it opens in compatability mode) and see the template that's attached is the correct one.[/quote]
    Could it be a timing issue: is it possible that Word is not loading the "real" template by the time you request the name?

  3. #3
    2 Star Lounger
    Join Date
    Jun 2001
    Location
    York, Pennsylvania, USA
    Posts
    164
    Thanks
    0
    Thanked 3 Times in 2 Posts
    [quote name='jscher2000' post='763729' date='05-Mar-2009 16:31']Could it be a timing issue: is it possible that Word is not loading the "real" template by the time you request the name?[/quote]

    If I put a stop in the code just after the document is opened, wait a bit, then step into the code to get the name, it remains the same unfortunately.

  4. #4
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post
    [quote name='mdenison' post='763577' date='05-Mar-2009 08:49']I can manually open the same document (it opens in compatability mode) and see the template that's attached is the correct one.[/quote]

    Having opened the document manually in 2007, and verified that the correct template is attached; What does your snippet of code return?
    Regards
    Don

  5. #5
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts
    [quote name='mdenison' post='763879' date='06-Mar-2009 06:37']If I put a stop in the code just after the document is opened, wait a bit, then step into the code to get the name, it remains the same unfortunately.[/quote]
    How about ActiveDocument.BuiltInDocumentProperties(wdPropert yTemplate) -- is that accurate?

Posting Permissions

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