--------------------------- Microsoft Visual FoxPro --------------------------- File access is denied c:\program files\microsoft visual foxpro 9\foxrefs.dbf. --------------------------- OK --------------------------->Another sample using VFPOLEDB.
>Wait Window Nowait "Creating Word Document.Please wait..." >* Word constants header file >#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 > > * Write mailmerge as if not using a template > .Application.Selection.TypeText("Dear,"+Chr(13)) > With .Application.Selection.Font > .Name = 'Times New Roman' > .Italic = .T. > .Size = 14 > Endwith > .Fields.Add(.Application.Selection.Range, 'First_Name') > .Application.Selection.TypeText(',') > .Fields.Add(.Application.Selection.Range, 'Last_Name') > With .Application.Selection.Font > .Name = 'Times New Roman' > .Italic = .F. > .Size = 10 > Endwith > .Application.Selection.TypeText(NL+NL+; > 'Please update your info and send back. Current notes are as follows:'+; > NL+NL) > With .Application.Selection.Font > .Name = 'Arial' > .Size = 12 > .Color = Rgb(0,0,255) > Endwith > .Fields.Add(.Application.Selection.Range, 'Notes') > * Write mailmerge as if not using a template > > * Send to a new doc - to check what we get > .Destination = wdSendToNewDocument > .Execute > Endwith > .Visible = .T. && Show word app > .Activate >Endwith >Wait Clear >Erase (m.lcSource) >**** Set the LocaleId to the previous value >=Sys(3006,Val(nlLocaleId)) >Cetin