Wait Window Nowait "Creating Word Document.Please wait..." * Word constants header file - you can create this file using object browser * Drag&drop constants node from MS Word COM on to an open code window * and save as wdconst.h #include "wdconst.h" #Define NL Chr(13)+Chr(10) m.lcConnection = "Provider=VFPOLEDB;Data Source="+_samples+'data\testdata.dbc' TEXT TO m.lcUDL TEXTMERGE noshow [oledb] <<m.lcConnection>> ENDTEXT m.lcSource = Forcepath(Sys(2015)+'.udl',Sys(2023)) Strtofile(m.lcUDL,m.lcSource) lcSQLStatement = "select first_name,last_name,title,hire_date,notes from employee" *** set the LOCALEID to English nlLocaleId=Sys(3004) && Save local id =Sys(3006,1033) && We will be sending instructions in English *** set the LOCALEID to English oWordDocument=Createobject("word.application") && Create word object With oWordDocument .documents.Add With .ActiveDocument.Mailmerge .OpenDataSource(m.lcSource, wdOpenFormatAuto,,,.T.,,,,,,,m.lcConnection, m.lcSQLStatement) .EditMainDocument && Activate the main document ..... ENDWITH ..... ENDWITH>My issue is (I think???), I have used 2 datasources in the past (2000, 2003) to produce this memo. I used a headersource and datasource for the top of the memo and inserted a table query for the bottom of the memo. Word2007 broke that. It appears I have to use one odc file to attach one datasource. The code below was my attempt to open the datasource directly, using an odc file...in my dreams I guess!
>>>oWord=GETOBJECT('','word.application') >>>oDoc=oWord.Documents.Open("filePath+docName") >>>oDoc.MailMerge.OpenDataSource("dbfPath+dbfName", 0, 0, 1, 0, "", "", 0, "", "", "Entire Spreadsheet", "", "" ) >>>>>
>>oWord = GETOBJECT('','word.application') >>oDoc = oWord.Documents.Open(filePath+docName) >>oDoc.MailMerge.OpenDataSource(dbfPath+dbfName, 0, 0, 1, 0, "", "", 0, "", "", "Entire Spreadsheet", "", "" ) >>>>