PDA

View Full Version : Solved: SaveAs - except macros



MK_
05-19-2011, 07:09 PM
Hi all,

I have a Word doc with a big set of macros to perform several operations over data entered trough an userform and finally does a "ActiveDocument.SaveAs" to create another doc, keeping itself untouched.
I´m looking for a way to save that new file without the macros and userform from the "master" file.
The reason for such a "strange" solution is that I want exactly the same file, with all formats, including header and footer. The "SaveAs" solution seems to be the best idea, except for the macros and userform it carries from the first file.

I'm using MS Word 2003.

Thanks in advance for any help.

gmaxey
05-20-2011, 04:36 AM
Create a template (.dot) containing your UF and code modules. Create new documents based on the template and save the new document as a document file (.doc)

MK_
05-21-2011, 01:17 PM
Thanks Greg, it solves, but the new file (in fact the "project") contains a reference to the dot file.
I think there's no problem, because even if I suppress (rename) the dot file, the doc opens fine, but is there an elegant way to cut this reference?

Frosty
05-22-2011, 05:10 PM
Change the ActiveDocument.AttachedTemplate property to "Normal" or "" or something else.

However... be aware that the moment you lose the reference to the original template (with the code in the project), you may terminate any subsequent code to be run, if the project has no reason to stay loaded.

MK_
05-22-2011, 06:27 PM
Thanks Frosty.