Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS Word Save Without VBA Code

Status
Not open for further replies.

DJSmith

Programmer
Aug 14, 2000
82
GB
Hi,

I have a word document that contains a reasonable about of VBA code that is used to generate a word document. As one of the last steps of the process the document is is Saved As. Unfortunately as part of this process the macro code is also saved into the new document.

Is there anyway of removing the code when the save is performed so that the user does not have to click on "Enable Macros" (Without changing the security settings) every time they want to open the document??

Thanks

DJ.
 
VBA code that is used to generate a word document
If you create a new document, no VBA code will be added.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Sorry PHV, but if you do a SaveAs, as was stated, all VBA code is preserved in the "new" document.

DJSmith, Have you done a search for how to remove all VBA code modules?

Depending on file size, you could just copy and paste the document itself (rather than SaveAs). No code would make it then - well depending on what you have in Normal.dot.

However, there are ways to remove VBA code, using VBA.



Gerry
 
fumei, I didn't mention SaveAs.
My suggestion was to create a brand new document.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
As far as I understand your problem all you have to do is cycle through the VBproject components as part of the Document_Close sub and simply remove them. This would however leave one piece of code...the component remover...would this be a problem to you?
 
How about saving as RTF?

RTFs don't contain macros... ;-)
 
Uh, sorry PHV, my literalist POV again. I did not read it as a suggestion, which it was. Apologies. I was responding too literally to the original post where the process was a SaveAs. Yes, creating a new document would solve the issue. The whole document would have to be cut and paste, and if there was an original template attached, that would also have to be attached first to the new document, as well. Otherwise any styles in the paste would come out incorrect.

Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top