USE doaTWO # DEFINE CRLF CHR(13)+CHR(10) # include wdtylb.h RELEASE oWord oWord = CreateObject("Word.Application") WITH oWord .Visible = .t. .ChangeFileOpenDirectory(SYS(5)+CURDIR()) SCAN .Documents.Open("DBEN2x.doc",.f.,.f.,.f.,"","",wdOpenFormatAuto) .ActiveDocument.SaveAs("DBENFILLED.Doc",wdFormatDocument,.f.,"",.t.,"",.f.,.f.,.f.,.f.,.f.) if gotoBookMark("TODAY") = 2 .selection.insertafter(CMONTH(DATE())+" "+ALLTRIM(STR(day(DATE())))+", "+ALLTRIM(STR(YEAR(DATE())))) ENDIF if gotoBookMark("BENE_NAME_ADDR") = 2 .Selection.insertafter(BENNAME+CRLF+BENADR1+CRLF+BENADR2+IIF(!EMPTY(benadr3),CRLF+BENADR3,"")) ENDIF if gotoBookMark("EMPNAME") = 2 .Selection.insertafter(EMPNAME) ENDIF if gotoBookMark("EMPNAME2") = 2 .Selection.insertafter(ALLTRIM(EMPNAME)) ENDIF if gotoBookMark("EMPNAME3") = 2 .Selection.typetext(ALLTRIM(EMPNAME)+" "+EMPSSNO+SPACE(15)) ENDIF .printout .activedocument.close WAIT TIMEOUT 5 ends WAIT TIMEOUT 5 .quit endw rele oword CLOSE all ********************************* func GoToBookMark ********************************* lPara tcBookMark if vartype(tcBookMark) # "C" or empt(tcBookMark) retu 0 endi if ! oWord.ActiveDocument.BookMarks.Exists(tcBookMark) retu 1 endi oWord.Selection.Goto(-1,,,tcBookMark) retu 2