Results 1 to 7 of 7
  1. #1
    New Lounger
    Join Date
    Oct 2002
    Location
    Stevenage, Bedfordshire, England
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unexpected Template Association (Win 2k/Word 2k)

    I have a Word document which has a template l've created attached to it (called Letters.dot). One of the events in the template is to run a mail merge, the resulting merged document then has the attached template changed from Letters.dot to 'Normal.dot'.

    The problem is that when l go to close down this new document, it brings up a save dialog from my Letters.dot template, even though the template is not listed in its 'Templates and Add-ins', or as a reference in the VB editor window. Even more bizarrely, if l open up an entirely new instance of Word from the start bar, this too shows the letters.dot dialog. But if l close down my original document, the one that does correctly have my template associated with it, the other documents behave normally.

    Surely l can have different documents using different templates open at the same time without them affecting each other? ...even as l'm writing this, l have a memory sparked off about MDI and SDI. Even though Word appears to be SDI, is it in reality multiple document interface? It's the only thing l can think of.

    Many thanks for any suggestions...

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Unexpected Template Association (Win 2k/Word 2k)

    Word is a Multiple Document Interface application - always has been. Microsoft decided that this was too confusing for the users, so in Office 2000, they decided to have it masquerade as a Single Document Interface application. Underneath, there is still a single instance of Word running.

    Does it help if you set

    ActiveDocument.AttachedTemplate.Saved = True

    just before unlinking the document from Letters.dot, or

    Templates("...Letters.dot").Saved = True

    (where ... is the complete path) after unlinking the document?

  3. #3
    New Lounger
    Join Date
    Oct 2002
    Location
    Stevenage, Bedfordshire, England
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Unexpected Template Association (Win 2k/Word 2k)

    Thanks for your reply Hans. I set the 'saved' value to true either side, ie, set saved to true for the 'Letters.dot' template, set a new AttachedTemplate value (ie, normal.dot) and set saved true again, just to be double sure l don't get asked to save the template at any point.

    I guess this single instance of Word with multiple windows is why l'm getting this strange behaviour, so any ideas on how to work around it?

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Unexpected Template Association (Win 2k/Word 2k)

    I don't really understand what is happening. That said, you might want to change all references to "ActiveDocument" to explicit object references that can't possibly accidentally refer to a different document.

  5. #5
    New Lounger
    Join Date
    Oct 2002
    Location
    Stevenage, Bedfordshire, England
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Unexpected Template Association (Win 2k/Word 2k)

    This is the problem you see, the new document doesn't have any code against it, no templates apart from 'Normal.dot', it's completely separate from my application which opens documents with my template attached, it's been opened through the start bar, not through my application.

    My template has code which replaces Word's save dialog with one of my own. But if while having one of my documents open, they open a completely new instance of Word, not through my application, then when they go to save, they still get my save dialog up, even though there is no apparent link to my template.

    I'm now looking at some code to make Word 2000 act like an MDI: http://forums.compuserve.com/GVForums/uk/F...&HMN=0&FID=3675, it's not a perfect match, but it will at least mean that users will only be able to have my Word-opening application open, any new documents will be added to the MDI, and by default become documents in my application.

  6. #6
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Unexpected Template Association (Win 2k/Word 2k)

    > My template has code which replaces Word's save dialog with one of my own.
    Are you doing this with just replacement macros (e.g., Sub FileSave) in the document template, or with event handlers? Either way, maybe we can think of a way to tighten that up.

  7. #7
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Unexpected Template Association (Win 2k/Word 2k)

    The number of windows has no effect on whether Word wants you to save a docc or template.

    I would guess that the code in one of your templates is affecting the Normal template, or vice versa.

Posting Permissions

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