-
For code to run when a document is created from a template, it needs to be in a routine named Document_New in the ThisDocument object or AutoNew in a standard Module. And I assume that is where you have the MsgBox command in the normal.dot template.
While the subject of your post says "newly created", your code is actually opening a document "myNewsLetter"
For a code to run when a document is opened, it needs to be in a routine Document_Open in the ThisDocument object or AutoOpen in a standard module.
Unless you want this routine to run every time you open any document, I would not have it in the Normal.dot template.
If you really are wanting to create a new document, it would be better to save the file that is opened as "myNewsLetter" as a template and have the code that you want to run in a Document_New or AutoNew routine in that template. If that template was named "myNewsLetter", then in your VB.Net code, you would use:
[vba]MSDoc = MSWord.Documents.Add("[templates path]\myNewsLetter")[/vba]
in place of:
[vba]MSDoc = MSWord.Documents.Open(myNewsLetter)[/vba]
You need to substitute the drive:\path to the template for the [Template Path] in the above code.
It's probably better however to have the code in the VB.Net routine.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules