Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Nov 2002
    Thanked 0 Times in 0 Posts

    VBA code does not get placed into saved doc (Word 2000/SR1)

    We have created Word templates with VBA code and we have noticed that a saved Doc file based on one of those templates does not contain the VBA code. We see how the doc file is referencing back to the template it was based on. In our case we need to be able to send a doc based on a template with VBA code to another person who may not have the template that the doc was based on. In Excel the VBA code that exists in an Excel template is passed onto to the saved workbook(xls). Is there some setting so that Word templates behave the same. I have included a screen shot of a simple template and doc I am using.
    Attached Files Attached Files

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 31 Times in 31 Posts

    Re: VBA code does not get placed into saved doc (Word 2000/SR1)

    Word has always behaved differently from Excel in this respect.

    When you create a new Excel workbook, the template is cloned: the new workbook is an exact copy of the template, complete with modules, userforms, etc., and there is no connection between the new workbook and the template.

    When you create a new Word document, the content and styles are copied from the template to the new document, but the modules, userforms, toolbar customizations, autotext entries etc. are left in the template; the document has a reference back to the template.

    Both approaches have advantages and disadvantages.

    I don't think that there is a setting to store everything in the document (and in the case of autotext entries, it is impossible). You can use the Organizer (Tools | Templates and Add-ins...) to copy modules from the template to the document, but you'll have to copy the code in ThisDocument by hand, but in general, but check carefully which code you want to copy.

Posting Permissions

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