#Define MYDBC _samples+"\DATA\testdata.DBC" #Define wdSendToEmail 2 #Define wdSendToFax 3 #Define wdSendToNewDocument 0 #Define wdSendToPrinter 1 cSQLStatement1 = "SELECT * FROM employee where title like [Sales%]" cSQLStatement2 = "" * Be carefull with where clause - where title = [Sales] fails * for ODBC uses ANSI SQL (exact match) * Two strings for first is limited to 255 chars oWordDocument=createobject("word.application") && Create word object With oWordDocument .Documents.Add(sys(5)+curdir()+'mmerge.dot') && Use a predefined template With .ActiveDocument.MailMerge .OpenDataSource(,,,.T.,,,,,,,, ; "DSN=Visual FoxPro Database;SourceDB="+MYDBC+; ";SourceType=DBC;Exclusive=No;",; cSQLStatement1, cSQLStatement2) && Open data source - Link to source .Destination = wdSendToNewDocument .Execute Endwith .Visible = .t. EndwithSourcetype=DBF is dangerous if your data has memo and probably would fail anywhere where MDAC2.1 or later is installed.