-
How to run a procedure in a Word Document as soon as it is newly created
I have a VS2010 Vb.net program that creates a Word 2007 file.
My Normal.dot file is customised to give me a new Tab with Buttons that do specific things via VBA in the Normal.dot program when those Buttons are pressed.
This all works fine, however, I now want to add some functionality whereas as soon as the new Word document is created, it edits a Task in Outlook via the VBA code (I have this code ready to apply, this is not the problem, I need to make it execute, that is the problem !).
I have edited the 2 "This Document" Procedures and you can see my Normal.Dot file in the attached Screenshot ... except you can't, why can't I load a screenshot from my PC ?!?!?
OK, under Project (NL Skeleton) which is the Word Document I use to update my Normal.dot template (although I now realise that it doesn't really work like that !) I have a basic MSGBOX command saying ...
[VBA]MsgBox ("NL Skeleton)"[/VBA]
... and under Project (Normal) I have a basic MSGBOX command saying ...
[VBA]MsgBox ("Normal)"[/VBA]
However, when I run my VB.Net program that creates a brand new Word 2007 document, the VBA code in the Normal.dot template does NOT stop on either of the message boxes, it just continues and opens the Word document exactly as before, my VB.net code is below, what am I doing wrong ?!?
[VBA]
'Open or Create Word document for Editing
myNewsLetter = myFolder + myLeague + "News" + mySession + ".doc"
If File.Exists(myNewsLetter) Then
'do nothing
Else
myTemplate = myTempFolder + "NL Skeleton.doc"
File.Copy(myTemplate, myNewsLetter)
Create_Blank_Newsletter()
End If
'Open Word Newsletter, or switch to it if it's already open
Dim myFileOpen As Boolean
myFileOpen = IsFileOpen(myNewsLetter)
If myFileOpen = False Then
MSDoc = MSWord.Documents.Open(myNewsLetter)
End If
MSWord.WindowState = Word.WdWindowState.wdWindowStateNormal
MSWord.Visible = True
MSWord.ActiveDocument.Bookmarks("\StartOfDoc").Select()
[/VBA]
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