Results 1 to 2 of 2
2003-06-19, 18:23 #1
- 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.
2003-06-19, 19:18 #2
- Join Date
- Mar 2002
- Thanked 30 Times in 30 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.