*!* Author: Cetin Basoz *!* MailMerge sample that works with newer versions too *!* Update: That is what I thought. But Office team likes to *!* change things with every new version. Doesn't work under *!* Office 2010 64 bits as is and I don't know why yet. Wait Window Nowait "Creating Word Document.Please wait..." #Define wdOpenFormatAuto 0 #Define wdSendToNewDocument 0 #Define wdSendToPrinter 1 #Define wdSendToEmail 2 #Define wdSendToFax 3 #Define wdAlertsNone 0 lcTemplateDoc = '' lcConnection = "Provider=VFPOLEDB;Data source="+_samples+'data\testdata.dbc' If !File('myDummy.udl') Strtofile('','myDummy.udl') Endif m.lcSource = Fullpath('myDummy.udl') lcSQLStatement = "select e.First_Name,e.Last_Name,e.Notes from [Employee] e" *** 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 If Empty(m.lcTemplateDoc) && No template .documents.Add() && New file Else .documents.Add(m.lcTemplateDoc) && Open a template Endif loDoc = .ActiveDocument With .ActiveDocument.Mailmerge .OpenDataSource(m.lcSource, wdOpenFormatAuto,.F.,,.T.,,,,,,,m.lcConnection, m.lcSQLStatement) .EditMainDocument && Activate the main document *!* Add some merge fields and typ text programmatically .Fields.Add(.Application.Selection.Range, "Last_Name") .Application.Selection.TypeText(", ") .Fields.Add(.Application.Selection.Range, "First_Name") With .Application.Selection.Font .Italic = .F. .Name = 'Arial' .Size = 10 Endwith .Application.Selection.TypeText(Chr(13)+"Here is your notes data :"+Chr(13)+Chr(13)) With .Application.Selection.Font .Bold = .T. .Color = Rgb(0,0,255) Endwith .Fields.Add(.Application.Selection.Range, "Notes") With .Application.Selection.Font .Bold = .F. .Color = Rgb(0,0,0) Endwith .Destination = wdSendToNewDocument .Execute() loDoc.Close(0) && closing the template doc - keep open to create your own template Endwith .Visible = .T. && Show word app .Activate .DisplayAlerts = wdAlertsNone .NormalTemplate.Saved = .T. Endwith **** Set the LocaleId to the previous value =Sys(3006,Val(nlLocaleId))Cetin