先观察一下表格再看看怎样处理好点,如:
oWord = CREATEOBJECT("Word.Application")
oWord.DisplayAlerts = .F.
oWord.Documents.Open("C:\TEMP\test.doc")
WITH oWord.ActiveDocument
FOR i=1 TO .Tables.Count
? "表格:"+TRANSFORM(i)
? "行数:"+TRANSFORM(.Tables(i).Rows.Count)
? "列数:"+TRANSFORM(.Tables(i).Columns.Count)
?
FOR nRow=1 TO oWord.ActiveDocument.Tables(i).Rows.Count
FOR nCol=1 TO oWord.ActiveDocument.Tables(i).Columns.Count
TRY
oCell = oWord.ActiveDocument.Tables(i).Cell(nRow, nCol)
? nRow, nCol, oCell.Range.Text
CATCH
? nRow, nCol, "不是对象"
ENDTRY
ENDFOR
ENDFOR
ENDFOR
ENDWITH
[此贴子已经被作者于2018-4-9 08:49编辑过]