> >objwordapplication = CREATEOBJECT("Word.Application") > >objworddocument = objwordapplication.Documents.Open(templatedoc) > >*-- Find the bookmark >oBookMark = objworddocument.Bookmarks["TestingTable"].Range >*-- Select the entire table >oTable = oBookMark.Tables[1].Range > >*-- How many rows are there? >nRowCount = oTable.Rows.Count >*-- Note: There are seven columns > >*-- Now, we will cycle first each row >FOR lnOnRow = 1 TO nRowCount > oItem = "NULL" > oItem =IIF(TYPE("oBookMark.Tables[1].Cell[lnOnRow,1].Range")=="O", ; > oBookMark.Tables[1].Cell[lnOnRow,1].Range.Text, oItem) > IF oItem = "insertrowafterhere" > llFlag = .T. > EXIT > ENDIF > IF llFlag > EXIT > ENDIF >NEXT >>
#Define wdSeparateByCommas 2 #Define wdSeparateByDefaultListSeparator 3 #Define wdSeparateByParagraphs 0 #Define wdSeparateByTabs 1 #Define TABULATE Chr(9) #Define NL Chr(13)+Chr(10) lcTempFile = Sys(2015)+'.tmp' Use employee Copy To (lcTempFile) ; fields First_Name, Last_Name, Title ; type Delimited With Tab ; for Upper(Title) = 'SALES' lnCols = 3 _Cliptext = Chrtran(Filetostr(lcTempFile),'"','') Erase (lcTempFile) oWordDocument=Createobject("word.application") && Create word object With oWordDocument .documents.Add && New file With .ActiveDocument.Range .Paste && Paste VFP data .ConvertToTable(wdSeparateByTabs,,lnCols) && Convert to table oTable = .Tables[1] Endwith *-- How many rows are there? nRowCount = oTable.Rows.Count nColCount = oTable.Columns.Count ? nRowCount, nColCount *-- Now, we will cycle first each row For Each oRow In oTable.Rows If oRow.Cells(1).Range.Text = "Nancy" If oRow.IsLast oTable.Rows.Add() Else oTable.Rows.Add(oTable.Rows(oRow.Index+1)) Endif Exit Endif Endfor .Visible = .T. EndwithCetin