************************************************** >* Start of code >************************************************** >select * from (home()+"samples\data\employee") into cursor wrdTest >* Replace with your select for invoice >_VFP.datatoclip(alias(),reccount(),3) && Copy VFP table to clipboard >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 > .appshow && Show word app > .filenewdefault && New file, default template - this is our main doc > * If you have a predefined doc template > * then instead of filenewdefault - fielopen(cTemplateDoc) > * Create datasource > .MailMergeCreateDataSource(sys(5)+curdir()+"xmergedoc") > .MailMergeEditDataSource && Edit data source > .editselectall && Select entire doc > .editpaste && Clipboard data pasted to word - paste over > * Remove spaces - otherwise header fail > .editfind(" ","",0,0,0,0,0,0,,1,,1) > .editfind("^t^p","^p",0,0,0,0,0,0,,1,,1) && Tab+para to para > .editselectall && Select entire doc > .texttotable(1) && Convert text to table - tabs (1) (Word table) > .MailMergeEditMainDocument && Activate the main document >* Now you have "MailMerge" toolbar and at the very left "Insert Merge field tab" >* You can also insert a merge field programmatically >* .InsertMergefield("address") >endwith > >**** Set the LocaleId to the previous value >=sys(3006,val(nlLocaleId)) > >************************************************** >* End of code >**************************************************This is again w95&w97 compatible word.basic code. VBA code is simplier for you can code it like VFP OOP. I prefer this one for it's compatible between versions.