I'm still having problems with this can anyone help here is the error message and code.
OLE IDispatch Exception Code 0 from Microsoft Word Word unable to open datasource.
It is Erroring at the .MailMergeOpenDataSource, where the set step on is.
Can anyone Help
local idx, vioid, vendid
set exclu off
set talk on
set dele on
set safe off
clear
with thisform
if not empty(.onevendor1.value)
idx = .vendorlist1.listindex
vncode = .vendorlist1.list(idx,2)
cvncode = vncode
endif
if not empty(.oneviolation1.value)
idx = .violations1.listindex
vioid = .violations1.list(idx,2)
cvioid = vioid
endif
dstartdate = ctod(.startdate1.value)
denddate = ctod(.enddate1.value)
if dstartdate = { / / } or denddate = { / / }
messagebox("Invalid Parameters - Include Startdate, Enddate",16)
.formerror()
return
endif
endwith
select vendcomply.vcid, vendor.vncontact, vendor.vnname, vendor.vnaddress1, vendor.vnaddress2,;
vendor.vncity, vendor.vnstate, vendor.vnpostal, iif(vendcomply.billpo=1,"PO #",""

as viol1,;
iif(vendcomply.billpallet=1,"Pallet Count",""

as viol2, iif(vendcomply.billcarton=1,"Carton Count",""

as viol3,;
iif(vendcomply.lblpo=1,"DDS PO# on Label",""

as viol4, iif(vendcomply.lblsku=1,"DDS Sku# on Label",""

as viol5,;
iif(vendcomply.lbldesc=1,"Item Desc on Label",""

as viol6, iif(vendcomply.lblum=1,"U/M per Carton",""

as viol7,;
iif(vendcomply.palstandar=2,"Sub Standard Pallets",""

as viol8, iif(vendcomply.pallblexp=1,"Carton Labels Exposed",""

as viol9,;
iif(vendcomply.paldimenio=1,"Product Contained to Pallet Dimenions",""

as viol10,;
iif(vendcomply.paldamage=2,"Product Damaged due to Improper Shipping",""

as viol11,;
iif(vendcomply.pklist=1 ,"Packing List Included",""

as viol12, iif(vendcomply.pkonlead=1,"On Lead Carton",""

as viol13,;
iif(vendcomply.pksku=1,"DDS Sku# on Packing List",""

as viol14, iif(vendcomply.pkpo=1,"PO# on Packing List",""

as viol15,;
iif(vendcomply.repack=1 ,"Re-Pack was Required",""

as viol16, iif(vendcomply.carrier=1,"There was a Carrier Issue",""

as viol17;
from Vendorcomply;
join vendor on vendor.vncode = vendcomply.vendid;
where vendcomply.vcdate between dstartdate and enddate;
order by 3,1;
group by 3,1;
into table (sys(2023) + "\Testdata"
copy to c:\VFP\Testdata.dbf delimited
public oword
oword = createobject("Word.Basic"

with oword
.appshow && Makes Word Visible
.filenewdefault && Opens up blank Word document
.mailmergemaindocumenttype(0) && the active window a document
* Open the data source
* The following command uses C:\VFP as the path
* to the data source
set step on
.MailMergeOpenDataSource("C:\VFP\testdata.dbf",0,0,1,0,"", ;
"",0, "","","DSN=FoxPro Files;DBQ=C:\VFP;DefaultDir=C:\VFP ;
Deleted=1;DriverId=24;JetIniPath=odbcddp.ini;Statistics=0;", ;SELECT * FROM testdata.dbf",""
* Activates the mail merge main document
.mailmergeeditmaindocument
* The following Insert commands place text into the Word
* document. You can change these commands to place any text in
* the document. This example uses a typical business letter
* format.
return
.insert("550 College Terrace"

&& Inserts a string
.insertpara && Inserts a carriage return
.insert("Orangeburg, SC 29915"

.insertpara
.insertpara
.insertmergefield("vnname"

.insertpara
.insertmergefield("vnaddress1"

.insertpara
.insertmergefield("vncity"

.insert(", "

.insertmergefield("vnstate"

.insertpara
.insertmergefield("vnpostal"

.insertpara
.insertpara
.insertpara
.insert("Dear "

.insertmergefield("vncontact"

.insert(","

.insertpara
.insertpara
.insert("Thank You For Your Support."

.insertpara
.insertpara
.insertpara
.insert("Sincerely,"

.insertpara
.insertpara
.insertpara
.insert("Traci Graski"
* Merges data records with the main document
.mailmergetodoc
* Saves the active document with the specified name
.filesaveas("c:\lett.doc"

endwith