************************************************** * Start of code ************************************************** PUBLIC oWordDocument *** set the LOCALEID to English nlLocaleId=sys(3004) && Save local id =sys(3006,1033) && We will be sending instructions in English WAIT window nowait "Creating Word Document..." && Inform user oWordDocument=createobject("word.basic") && Create word object WITH oWordDocument .filenew("c:\temp\mmtemplate.doc") && open using template table * This needs template file already EXISTS ! * Template based on testdata!employee for sampling cDSN = "DSN=Visual FoxPro Tables;UID=;PWD=;" cSourceDb = "SourceDB="+home()+"SAMPLES\DATA\Testdata.dbc" cSourceType = ";SourceType=DBC;" cOther = "Exclusive=No;BackgroundFetch=No;Collate=Machine;" cSQLStatement = "SELECT * FROM employee where title like [Sales%]" * Be carefull with where clause - where title = [Sales] fails * for ODBC uses ANSI SQL (exact match) .MailMergeOpenDataSource(,,, 1 ,,,,,,,; cDSN+cSourceDb+cSourceType+cOther, ; cSQLStatement) && Open data source - Link to source .MailMergeEditMainDocument && Activate the main document lnActiveWindow = ltrim(str(.window())) && Get active doc window number .MailMergeToDoc && Merge to a new document && To print directly: .MailMergeToPrinter .window&lnActiveWindow && Activate template window .fileclose(2) && Close file wait clear .appshow && Show word app ENDWITH **** Set the LocaleId to the previous value =sys(3006,val(nlLocaleId)) ************************************************** * End of code **************************************************Cetin