Delete VBA code in runtime

F

Flemming Dahl

Hi,

I have the below code in ThisModule of severel templates. It calls and
add-in that do some stuff.....

Now I would like the finished documents to be without code in ThisModule, so
that when a user mails the documents to a customer or.... the documents will
not be stopped in AntiVirus systems, that does not allow VBA code.

Can I delete all the code in ThisModule in run-time ?

Thanks,
Flemming

-----

Private Const msNAME As String = "EN.dot"
Private msFullFileName As String

Private Sub Document_New()
' Code
' Code

'DELETE IT ALL........

End Sub

Private Function FileExists(ByRef sFullPathAndFileName As String) As Boolean
' Returns True if the file exists
FileExists = CBool(Len(Dir(sFullPathAndFileName)))
End Function
 
H

Helmut Weber

Hi Flemming,
if you create a document (!) from a template (!),
it doesn't contain code anyway.
Or am I missing the point?

Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
 
P

Pete Bennett

It's probably worth pointing out that it IS possible to remove VBA code and
modules using runtime VBA code, but Word will still think that the
document/template contains VBA code and will still trip the Macro Security
message when you open the document next time around.

The only way (that I know) to really rmove macros is to copy the content of
the document into a new container.
 
F

Flemming Dahl

Thanks for your reply - I will have your notes in mind for a later project.

Thanks,
Flemming
 
F

Flemming Dahl

Ofcause - You are so right - the document does not contain code - the code
is in the Attached Template, and I can change the Attached Template to
Normal, if I need to.

Thanks,
Flemming
 

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