Doing a mailmerge using the following code works with Office 2000 but not Office 2003 and gives this error:
1429 OLE IDispatch exception code 0 from Microsoft Word: 'Destination' is not a by reference property... .Destination = wdSendToNewDocument
Any suggestions?
*-------------------------------------------------
#Define CR CHR(13)
#Define wdWindowStateNormal 0
#Define wdWindowStateMaximise 1
#Define wdOpenFormatAuto 0
#Define wdSendToNewDocument 0
#Define wdSendToEmail 2
#Define wdDefaultFirstRecord 1
#Define wdDefaultLastRecord -16
#Define wdDoNotSaveChanges 0
Release ALL LIKE o*
Erase C:\AA_VFP\BOOKINGFORM.DOC
Public oWord
Local oDoc, oRange, cText, oHeaderStyle
oWord = CreateObject("Word.Application")
*!* oWord.Visible = .T.
oWord.Documents.Open("C:\AA_VFP\BFmerge.doc")
With oWord.ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = .t.
*!* .MailAddressFieldName = "ptuite@btconnect.com"
.MailSubject = "This email generated by animal Aunts Booking System"
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
Endwith
.Execute(.f.)
Endwith
oWord.ActiveDocument.SaveAs("C:\AA_VFP\BOOKINGFORM.DOC")
*!* oWord.Options.SendMailAttach = .t.
*!* oWord.ActiveDocument.SendMail
oWord.Quit(wdDoNotSaveChanges)
Release oWord
Patrick Tuite
1429 OLE IDispatch exception code 0 from Microsoft Word: 'Destination' is not a by reference property... .Destination = wdSendToNewDocument
Any suggestions?
*-------------------------------------------------
#Define CR CHR(13)
#Define wdWindowStateNormal 0
#Define wdWindowStateMaximise 1
#Define wdOpenFormatAuto 0
#Define wdSendToNewDocument 0
#Define wdSendToEmail 2
#Define wdDefaultFirstRecord 1
#Define wdDefaultLastRecord -16
#Define wdDoNotSaveChanges 0
Release ALL LIKE o*
Erase C:\AA_VFP\BOOKINGFORM.DOC
Public oWord
Local oDoc, oRange, cText, oHeaderStyle
oWord = CreateObject("Word.Application")
*!* oWord.Visible = .T.
oWord.Documents.Open("C:\AA_VFP\BFmerge.doc")
With oWord.ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = .t.
*!* .MailAddressFieldName = "ptuite@btconnect.com"
.MailSubject = "This email generated by animal Aunts Booking System"
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
Endwith
.Execute(.f.)
Endwith
oWord.ActiveDocument.SaveAs("C:\AA_VFP\BOOKINGFORM.DOC")
*!* oWord.Options.SendMailAttach = .t.
*!* oWord.ActiveDocument.SendMail
oWord.Quit(wdDoNotSaveChanges)
Release oWord
Patrick Tuite