remove macro after making a .doc from a .dot

R

RAO

Hi!

I am making a template with a VBA userform. However when the user has filled
in the form and saves the resulting .doc, how can the macro be automatically
removed from that .doc so that it is macro free and ready to be sent to a
third party?

I want that third party to be able to open a clean file without that same
userform popping-up. And preferably without macro's whatsover (don't want to
raise suspicion to that end-user because word will tell them that macro's
might contain a virus, depending on their security settings)

cheers!

RAO
 
P

Pranav Vaidya

Hi Rao,

You must store all your code inside the New event of the document template.
This event occurs when a new document based on the template is created. A
procedure for the New event will run only if it is stored in a template.

In short a new doc is created by Word without copying the VBA code.

Hope this helps!!
 
R

RAO

Thanks for the fast answer.

However, what exactly do you mean by 'new event'?

I have stored my code in the 'TemplateProject', where
else could I store it?

cheers
Rao
 
P

Pranav Vaidya

Hi Rao,

if you go to your VBA IDE, you will see 'Microsoft Word Objects'. Under this
you will see ThisDocument. Double click on this. Now from the code window,
the default is (General), change this to Document. The right hand side will
now show the events that are availabel under this document.

Select New from the right hand drop-down and move your code there.
 
S

Shauna Kelly

Hi RAO

If you have code in a template, and you create a new document from that
template, then the document stores *none* of the code from the template.
Excel works differently, so if you're used to Excel, this may seem a little
strange.

But you must be using a real Word template - not a Word document in
disguise. There are two ways to create a template:
1. (The better, cleaner way) File > New. In the task pane, click "On my
computer". In the bottom right of the dialog box, choose Template.

2. (The not so good way) Create a document and do File > Save and save as a
template.

For more information see
What is the relationship between a Word document and its template?
http://www.ShaunaKelly.com/word/templaterelations/index.html

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
 

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