Vba code is copied in word 2003 doc when generated from template by automation

D

dwien

Hi,

If I use the automation code below, then the vba code (code in thisdocument,
modules and classes) is copied in the new document generated.
I did the check to open the document on an other computer that doesn't have
the template on his harddrive and there you can see the complete code, too.

How can I avoid that hte code is embedded inside the new generated document.

Thanks
Edwin


Private Sub test()

Dim oWordApp As Word.Application
Dim oWordDoc As Word.Document
Set oWordApp = GetObject(, "Word.Application")
If Err <> 0 Then
Set oWordApp = CreateObject("Word.Application")
End If
With oWordApp
Set oWordDoc = .Documents.Add("c:\test\template.dot")
With oWordDoc
.Generatetest 1, 1
End With
End With
Set oWordDoc = Nothing
Set oWordApp = Nothing

End Sub
 
J

Jezebel

What does GenerateTest do?

But the short answer is, put the code in a template and use the normal new
document methods. Code in a template is not automatically copied to a new
document based on the template.
 

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