LPARAMETERS pdocument, pprop_key #DEFINE wdMainAndDataSource 2 #DEFINE wdSendToPrinter 2 #DEFINE wdDoNotSaveChanges 0 #DEFINE wdWindowStateMinimize 2 #DEFINE wdOpenFormatText 4 SET MEMOWIDTH TO 255 Local nLocaleID,lcTemp,lcHeader Local loWord,llToPrinter,lcSourceDoc *#include "wdconst.h" SET SAFETY OFF CD C:\VPMAPPS\TLP *!* OPEN DATABASE ATLP_V SHARED *!* SELECT * FROM property_v WHERE .t. INTO CURSOR t1 jprop_key=pprop_Key SET MEMOWIDTH TO 255 Select; cprimary_owner as OwnerName,; cname2,; cname3,; cco_line as CareOfName,; caddress_b as Address,; ccity_a as City,; cstate_b as StateOrProvince,; czip_a as PostalCode,; cname as CountyName,; caddress_c as CountyAddress1,; caddress2 as CountyAddress2,; ccity_b as CountyCity,; cstate_c as CountyState,; czip_b as CountyZip,; cphone_b as TreasurerPhone,; ctownship as TownshipRange,; csection as Section,; nparcel_no as ParcelNumber,; MLINE(clgl_desc,1) as LegalDescription,; MLINE(cgeocode,1) as Geocode,; SPACE(10) as DateOfNotice; From property_v Where cprop_pk=jprop_key And .T. Into Cursor merge_cursor readwrite IF !EMPTY(jdate_of_notice) REPLACE DateOfNotice WITH DTOC(jdate_of_notice) all endif SELECT merge_cursor lctemp=CURDIR()+'form_letters\tlp.tmp' Copy To (lctemp) Type Delimited With "" With Tab AFIELDS(laFields) lcHeader = '' For ix = 1 To Fcount() lcHeader = lcHeader + ; Iif(Empty(m.lcHeader),'',Chr(9)) + ; Field(m.ix) Endfor lcSourceDoc = CURDIR()+'form_letters\mergesource.txt' Strtofile(lcHeader+Chr(13)+Chr(10)+Filetostr(lcTemp),lcSourceDoc) WAIT WINDOW NOWAIT 'Creating Word Merge Document...' oWord = CREATEOBJECT("Word.Application") oWord.Visible = .T. oDoc = oWord.Documents.Open(CURDIR()+"form_letters\"+pdocument) oDoc.MailMerge.MainDocumentType = 0 oDoc.MailMerge.OpenDataSource(lcSourceDoc) oDoc.MailMerge.DataSource.FirstRecord = oDoc.MailMerge.DataSource.ActiveRecord oDoc.MailMerge.DataSource.LastRecord = oDoc.MailMerge.DataSource.ActiveRecord oDoc.activate && Make it the active foreground app *oDoc.MailMerge.Execute