Disable VBA

G

Geoff332

Hi,

I have a bunch of documents that use all sorts of macro code to format and
control the document. The documents are all based on a template and the code
is located in the template.

I want to add a "publish" function that will prepare the document for
sending out to customers (update a few fields, set document protection etc).
At the completion of the publish function, I want it to either disable or
remove the macros from the published instance document. This is important,
because we don't want to expose the macros and other bits and pieces to our
customers (or even to have the warning dialogue pop-up).

Is this possible?

The second piece that would be wonderful is to add the ability to reactivate
the code from the original template, to allow us to manage and update the
document. I can assume that the original template is available for this
function.
 
J

Jonathan West

Geoff332 said:
Hi,

I have a bunch of documents that use all sorts of macro code to format and
control the document. The documents are all based on a template and the
code
is located in the template.

I want to add a "publish" function that will prepare the document for
sending out to customers (update a few fields, set document protection
etc).
At the completion of the publish function, I want it to either disable or
remove the macros from the published instance document. This is important,
because we don't want to expose the macros and other bits and pieces to
our
customers (or even to have the warning dialogue pop-up).

Is this possible?

If you create a document based on a template, the macros are not contained
in the document. The macros in thwe template remain available because the
document references the template. If you send a document out to a customer
without sending the template, the customer will not have the macros. You
don't need to take any special action to achieve this.
The second piece that would be wonderful is to add the ability to
reactivate
the code from the original template, to allow us to manage and update the
document. I can assume that the original template is available for this
function.

provided that you re-open the document on a PC that has the template, then
the macros will be automatically available again. Provided the template is
in the same location as fore, or is in one of Word's recognised locations
(e.g. in the user templates folder) then again, no special action is
required.
 
J

Jay Freedman

Hi,

I have a bunch of documents that use all sorts of macro code to format and
control the document. The documents are all based on a template and the code
is located in the template.

I want to add a "publish" function that will prepare the document for
sending out to customers (update a few fields, set document protection etc).
At the completion of the publish function, I want it to either disable or
remove the macros from the published instance document. This is important,
because we don't want to expose the macros and other bits and pieces to our
customers (or even to have the warning dialogue pop-up).

Is this possible?

The second piece that would be wonderful is to add the ability to reactivate
the code from the original template, to allow us to manage and update the
document. I can assume that the original template is available for this
function.

You're under the mistaken impression that the macros from the template are
duplicated in the documents based on the template. They are not. The macros are
available when the document is open *on your computer* because the document
maintains a link to the template (visible in the Tools > Templates & Add-ins
dialog).

When you send the document to another computer that doesn't have the template,
the macros will not be available there. Because the original template isn't
available, the document will be attached to the recipient's Normal.dot template
instead.

When the document is returned to you, use the Tools > Templates & Add-ins dialog
to reattach it to the original template. Then the macros will be available
again.

For more discussion, see
http://www.shaunakelly.com/word/templaterelations/index.html.
 
G

Geoff332

Thanks to both of you. I thought Word embedded the template macros in each
instance of the document (the way it does with styles). Obviously, this isn't
an issue.
 
J

Jonathan West

Geoff332 said:
Thanks to both of you. I thought Word embedded the template macros in each
instance of the document (the way it does with styles). Obviously, this
isn't
an issue.

Its an easy mistake to make, especially as other Office apps behave
differently. For instance, Excel VBA macros *are* embedded in new workbooks
based on an Excel templates. These little inconsistencies in the way Office
works all make for an interesting time :)
 

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