MS Word Mail Merge File Path Error

abbaddon223

Registered User.
Local time
Today, 07:05
Joined
Mar 13, 2010
Messages
162
Hello experts,

I'm trying to get a word document which has already been merge into an MS Access 2010 DB to open, merge and print with VBA.

The code I have is

Private Sub Command2_Click()
Dim oMainDoc As Word.Application

Dim oSel As Word.Selection
Dim sDBPath As String

Set oMainDoc = oApp.Documents.Open("D:\Remote Applications\AIA Invoice Management\Merges\7 Day Chase.dotx")
oApp.Visible = True

With oMainDoc.Documents.Add.MergeDoc


.MainDocumentType = wdFormLetters

sDBPath = "D:\Remote Applications\AIA Invoice Management\I-Track.mdb"
.OpenDataSource Name:=sDBPath, _
SQLStatement:="SELECT * FROM [Merge_Chase_1]"

End With

With oMainDoc
.Documents.Add.MergeDoc.Destination = wdSendToNewDocument
.Documents.Add.MergeDoc.Execute
End With

oApp.Activate
oApp.Documents.Parent.Visible = True
oApp.Application.WindowState = 1
oApp.ActiveWindow.WindowState = 1
End Sub

However I get the following error:

"Object Required"

At the below stage

Set oMainDoc = oApp.Documents.Open("D:\Remote Applications\AIA Invoice Management\Merges\7 Day Chase.dotx")

The file path is correct, so I'm assuming something in the code is wrong? I'm an intermediate at VBA so any help would be greatly appreciated!!

Thanks.

Phil.
 
Please don't double post as it is against the forum rules.
 

Users who are viewing this thread

Back
Top Bottom