oWord = CREATEOBJECT("Word.Application") oDocument = oWord.Documents.OPEN("C:\Agrisoft\test.doc") *-- Set the range for the first table to bookmark "BM1" oRange = oWord.ActiveDocument.Bookmarks("BM1").Range *-- Create the table at the bookmark selected and fill it with data oTable = oDocument.TABLES.ADD(oRange,nRows,nCols) SELECT FirstTable nCounter = 1 SCAN oTable.Cell(1,1).RANGE.InsertAfter(FirstTable.SomeField1) oTable.Cell(1,1).RANGE.InsertAfter(FirstTable.SomeField2) nCounter = nCounter + 1 ENDSCAN *-- Set the range for the second table to bookmark "BM2" oRange = oWord.ActiveDocument.Bookmarks("BM2").Range *-- Create the table at the bookmark selected and fill it with data oTable = oDocument.TABLES.ADD(oRange,nRows,nCols) SELECT SecondTable nCounter = 1 SCAN oTable.Cell(1,1).RANGE.InsertAfter(SecondTable.SomeField1) oTable.Cell(1,1).RANGE.InsertAfter(SecondTable.SomeField2) nCounter = nCounter + 1 ENDSCANThe end result is that no matter how many rows the first table has, I can get the second table built and populated directly below it (or wherever I want) by presetting some bookmarks in the document and using them to set oRange before creating the table.
>oWord = CREATEOBJECT("Word.Application") >oDocument = oWord.Documents.OPEN("C:\test.doc") >With oRange.Find > .Text="SomeText" > lFound = .Execute >EndWith >>