*Create and save the template routine >#define wdFormatTemplate 1 >lcMYDBC = 'c:\myPath1\myDbc.dbc' >cSQLStatement1 = "SELECT * FROM employee" >cSQLStatement2 = "" > >oWordDocument=createobject("word.application") && Create word object >With oWordDocument > .Documents.Add && Use a predefined template > .ActiveDocument.SaveAs(sys(5)+curdir()+'mytemplate.dot', wdFormatTemplate) > With .ActiveDocument.MailMerge > .OpenDataSource(,,,.T.,,,,,,,, ; > "DSN=Visual FoxPro Database;SourceDB="+lcMYDBC+; > ";SourceType=DBC;Exclusive=No;",; > cSQLStatement1, cSQLStatement2) && Open data source - Link to source > .EditMainDocument && Activate the main document > Endwith > .Visible = .t. >Endwith > >* User modified and saved the template >* Merge routine >lparameters tcMyDBC && Might be from a different path >#Define wdSendToNewDocument 0 >cSQLStatement1 = "SELECT * FROM employee where title like [Sales%]" >cSQLStatement2 = "" > >oWordDocument=createobject("word.application") && Create word object >With oWordDocument > .Documents.Add(sys(5)+curdir()+'mytemplate.dot') && Use a predefined template > With .ActiveDocument.MailMerge > .OpenDataSource(,,,.T.,,,,,,,, ; > "DSN=Visual FoxPro Database;SourceDB="+tcMyDBC+; > ";SourceType=DBC;Exclusive=No;",; > cSQLStatement1, cSQLStatement2) && Open data source - Link to source > .Destination = wdSendToNewDocument > .Execute > Endwith > .Visible = .t. >Endwith >>Cetin