I have a VB application that emails orders. Each time a new order is placed a word document is built and sent to Outlook to be emailed. Word is then closed. This process works for the first document but on trying to send a second document I come up with the error# 4605 "This method or property is not available because the current mail merge main document has no merge fields."
I use the following code to open a new document.
Dim Retry as boolean
On error goto AppErr
Retry = false
set wrdApp = getobject(,"Word.Application.9"
if Retry = True the
set wrdApp= new Word.Application
end if
set wrdDoc = wrdApp.Documents.Open _(Filename:="c:\Champion\Email.doc"
wrdDoc.MailMerge.MainDocumentType = wdFormLetters
wrdDoc.MailMerge.OpenDataSource Name:="c:\Champion\EmailFax.mdb", _
LinkToSource:= True, Format:=wdOpenFormatAuto, Connection:= "Query qryOrder", SQLStatement:="Select * from [qryOrder]
I build the complete document in vba. The mailmerge fields are added with the following code
with wrdDoc.MailMerge.Fields
.add Range:=Selection.Range, Name:="VCON"
end with
It doesn't process when it passes through this code
I would appreciate any input
RCCoates
I use the following code to open a new document.
Dim Retry as boolean
On error goto AppErr
Retry = false
set wrdApp = getobject(,"Word.Application.9"
if Retry = True the
set wrdApp= new Word.Application
end if
set wrdDoc = wrdApp.Documents.Open _(Filename:="c:\Champion\Email.doc"
wrdDoc.MailMerge.MainDocumentType = wdFormLetters
wrdDoc.MailMerge.OpenDataSource Name:="c:\Champion\EmailFax.mdb", _
LinkToSource:= True, Format:=wdOpenFormatAuto, Connection:= "Query qryOrder", SQLStatement:="Select * from [qryOrder]
I build the complete document in vba. The mailmerge fields are added with the following code
with wrdDoc.MailMerge.Fields
.add Range:=Selection.Range, Name:="VCON"
end with
It doesn't process when it passes through this code
I would appreciate any input
RCCoates