UNSAVE MACROS CODE

A

Alok

Hi ,

I have written few macros in a document which finally creates a new document
prgrammatically.

Please tell me how to EXCLUDE the macros code in the new document created.
 
J

Jonathan West

Hi Alok

Code is not stored in a dcument when you create it using the Documents.Add
method. However, then the document is open, macros stored in the template it
is based on are still available for use. But the macros will not be
available if you send the document to another computer that does not have
the template.

This article may help you

What do Templates and Add-ins store?
http://word.mvps.org/FAQs/Customization/WhatTemplatesStore.htm
 
A

Alok

Hi Jona
I am not using document.add method to add the template but the saveas method
with the active document .but its still saving the macros as well.
I do not want to save the macros with the new doc.

Thanx for your help,anyways.
Regards,
alok
 
J

Jonathan West

Alok said:
Hi Jona
I am not using document.add method to add the template but the saveas
method
with the active document .but its still saving the macros as well.
I do not want to save the macros with the new doc.

If you use SaveAs to save a document under a new name when the document
contains macros, then the new file will also contain macros. But are you
sure your original document does contain macros? By default macros get saved
in a template, not a document, and are available to all documents based on
that template.

If the document does contain macros, I would strongly recommsn you change to
to being a template, and then create new documents based on it using the
Documents.Add method. Documents created by this route definitely do not
contain macros.
 
A

Alok

Hi Jon
I could save the macros in the .doc file and not in the normal.dot file.

I am also not too sure about document.add method if it only adds templates
to self.

If i save the ORIGINAL doc as .dot file and the tried saving the NEW file as
..doc file.
It works !!! as it does not contain macros .

BUT IT STILL adds the original file as a reference to the new doc.when i go
to alt+F11 (vba code editer).

Hope i am making myself understandable .

Thanks,
Alok
 
J

Jonathan West

Alok said:
Hi Jon
I could save the macros in the .doc file and not in the normal.dot file.

I am also not too sure about document.add method if it only adds templates
to self.

If i save the ORIGINAL doc as .dot file and the tried saving the NEW file
as
.doc file.
It works !!! as it does not contain macros .

BUT IT STILL adds the original file as a reference to the new doc.when i
go
to alt+F11 (vba code editer).

Hope i am making myself understandable .

No really. Forget about what you are doing in VBA at the moment. Simply
describe the overall task and the effect you are trying to achieve.
 
A

Alok

Ya Jon
Actually i want to have a dot file with macro .
Which when opened should open a new document with the same content and load
my macro wizard.
but this new file should NOT have any reference to the macros in the
vbaeditor.

Thanks Jon for the effort.
I really appreciate.
 
J

Jonathan West

Alok said:
Ya Jon
Actually i want to have a dot file with macro .
Which when opened should open a new document with the same content and
load
my macro wizard.
but this new file should NOT have any reference to the macros in the
vbaeditor.

Thanks Jon for the effort.
I really appreciate.

If you duse the Documents.Add method to create a document based on your
template, any toolbars and macros will be available to the user because the
document will be based on the template.

but the toolbars and macros are not stored in the document, so when you save
it and email it to someone without the template, they will not have your
macros.

This article may help you understand what is going on

What do Templates and Add-ins store?
http://word.mvps.org/FAQs/Customization/WhatTemplatesStore.htm
 

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