save document based on template without macro

R

rbchase1

Greetings All,
I have a problem I can't figure out.
I have been asked to create a form for a standard report that we need
to send to our customer every week. I have created a template that
contains 90 formfields that allow the user to enter all the necessary
information. The most important functionality involed in this
template is that it makes it easy to save a copy for our internal use,
and a subset of that copy as an aditional document for our customers
use.

Because some of the end users of this template are not very computer
savvy, I have decided to lock the template from the start. I also
decided that the easiest way for me to deploy this would be to
intercept the FileSave and FileSaveAs commands and simply direct them
to my macro so I don't have to make a custom button on each users
computer.

The Macro uses data from several of the formfields to create a
standard filename, then opens a FileSaveAs dialog to allow the user to
edit the name or path of the file to be saved.
This is done a second time after some automatic editting and
protection of the document occurs.
All of this works wonderfully.

The problem is that the macro is saved in the documents created my the
macro, and the macro continues to intercept the FileSave and
FileSaveAs commands.

Is there a way that I can save the documents created by the macro in
such a way that they no longer contain or recognize the macro that is
in the template?

Thanks for your help.
Rob
 
J

Jay Freedman

Hi Rob,

Unless you've gone to some unusual lengths to save the macros specifically
in the document (which is usually something you'd want to avoid anyway), the
macros are _not_ saved in the document. It may appear otherwise because the
document loads its base template into memory, and that makes the macros
available. You can check this by opening the Tools > Macro > Macros dialog
and setting the "Macros in" dropdown to the name of the document -- the list
will be empty. Now set it to the name of the template, and you'll see your
macros in the list.

To stop the macros, all you need to do is break the linkage between the
document and its original base template. To do this manually, in the Tools >
Templates & Add-Ins dialog click the Attach button and choose Normal.dot
instead of the original template. Now, if you look in the Tools > Macro >
Macros dialog, you should no longer see the FileSave and FileSaveAs macros
in the list.

To do the same thing in macro, execute the statement

ActiveDocument.AttachedTemplate = NormalTemplate

(Note that if this is in a macro inside the original template, it will
immediately stop that macro by unloading it from memory. Thus it should be
the last thing the macro does.)

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top