Running a Macro in Word On Open

duecesup

Registered User.
Local time
Today, 05:18
Joined
Nov 20, 2008
Messages
15
Hello all,
I have created a report in Access and have exported the document to word for editing. However, I need to complete a mail merge in word to see all of my entries. I have created a macro of the mail merge but need to know how to run the macro automatically when the Word document is opened.
Any suggestions
Thanks
 
Why not open Word from within Access and then place bookmarks where you want to insert data and then use something like this precedure to insert the text.
MsObjDoc is a global variable the Word.Document that is open.
Public Sub InsertText(BookMk As String, TextToInsert As String)
Dim WordRange As Word.Range
If MsObjDoc.Bookmarks.Exists(BookMk) Then
Set WordRange = MsObjDoc.GoTo(What:=wdGoToBookmark, name:=BookMk)
WordRange.InsertAfter TextToInsert
End If
End Sub

Cheers

john
 

Users who are viewing this thread

Back
Top Bottom