Results 1 to 9 of 9
  1. #1
    New Lounger
    Join Date
    Oct 2003
    Location
    Glenwood, Iowa, USA
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Template Macros Lost When Saved As Document (Word 2002)

    I searched through the lounge postings and could not find a solution to this problem (if if is a problem and not part of the application design):

    I have a number of Word document templates that contain purchase orders. These documents use tables and macros to calculate total cost for an item, the subtotal, and the grand total. The macros are in a module in the TemplateProject container in VBA.

    Everything works fine with the templates in Word 2000, and after getting a digital certificate, they almost work in Word 2002. The only problem I have left is that the macros disappear when I save the new document based on the template into a .doc file.

    Here's the scenario: Sometimes I cannot complete a purchase order, so I save the work-in-progress. When I reopen the file, all of the macros are gone and I can no longer calculate any items totals, subtotals, etc. Like I said earlier, the macros are located in a module in the template project, and I suspect that relocating them to another place my be the answer. But I don't want them to be in the normal.dot template because I want the table calculations to occur only when I am editing the purchase order documents.

    Thanks in advance for any help that you can provide.

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

    Re: Template Macros Lost When Saved As Document (Word 2002)

    As long as the document is associated with the template, all macros within the template should be available in the document. Just saving a document should not remove this association. If necessary, you can reattach the template through Tools | Templates and Add-Ins...; press the Attach... button to locate the template.

  3. #3
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Template Macros Lost When Saved As Document (W

    Hi Paul:
    There's something about your description that I find troubling. You say the "template macros are lost when saved as a document". I don't know why you would save a template as a document, anyway (unless I've misunderstood you). You should have one or more purchase order templates (one for each type of purchase order). Then you can have your macros either in those templates or in a separate global template (I agree they shouldn't be in normal.dot). When you want to create a new purchase order, you should be using File/New... & creating a document based on the template. Is that what you're doing?

  4. #4
    New Lounger
    Join Date
    Oct 2003
    Location
    Glenwood, Iowa, USA
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Template Macros Lost When Saved As Document (W

    Yes, I am creating documents based on the various Purchase Order.dot templates by using the File | New dialog box. If I do this and complete the purchase order, then there is no problem. The problem comes when I cannot complete the purchase order for some reason (end of the day, not all info is known, etc.), and I save the new document based on the template (as a .doc file). When I reopen this document, the macros are gone and I cannot perform any more calculations (which are done in the macros).

    BTW, I tried to re-attach the template to the document according to the instructions in another post above, but after unprotecting the document, performing the re-attchment, and protecting the document (for forms), it still doesn't work.

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

    Re: Template Macros Lost When Saved As Document (W

    Do you have code in the Document_New procedure or in an AutoNew macro (or called from there) in the templates that detaches the new document from the template (something like ActiveDocument.AttachedTemplate = "Normal")? On the other hand, that seems unlikely if you don't have the problem in Word 2000.

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

    Re: Template Macros Lost When Saved As Document (W

    Sounds to me like the macros are creating a New document based on the Normal template and do not attach the right template to lthe doc until the stuff completes, if even then.

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

    Re: Template Macros Lost When Saved As Document (W

    That occurred to me too, but Paul stated
    <hr>I am creating documents based on the various Purchase Order.dot templates by using the File | New dialog box.<hr>

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

    Re: Template Macros Lost When Saved As Document (W

    I would still suspect macro code.
    If it's not a macro code problem, then it's likely a fat finger problem.

  9. #9
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Template Macros Lost When Saved As Document (W

    Hi Paul:
    I just want to throw out some ideas. From what you are saying:
    1. You create a new document based on a purchase order template. I also gather that the document is a form & is protected, so I assume that your macros are run OnEntry or OnExit. At this point, the macros work fine, you say.
    2. You close the document before completing everything.
    3. You immediately reopen the document & the macros don't exist. Again, I assume that your form is still protected.

    When you reopen the document, is the same template attached? If not, are any of your macros attaching a different template? Do you have an AutoClose or AutoOpen macro that is attaching a different template?

    IF you look at <!mskb=209881>Microsoft Knowledge Base Article 209881<!/mskb>, it explains instances when a document will lose it's attached template (in Word 2000). In the event that you have more than one template with the same name, it could be that another template is being attached. See <!mskb=220502>Microsoft Knowledge Base Article 220502<!/mskb> for the order in which Word searches for a template.
    Hope this helps,

Posting Permissions

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