-1

我想循环通过一个 dbf 并为满足条件的每条记录创建单词表,我得到了一个单页报告,其中只有一个表中的最后一个记录。看起来所有记录都写入同一个表。我尝试使用 n = n + 1 将变量作为元素放入表 oTable = oDoc.tables[n] 但似乎它只支持数字而不是变量?

4

1 回答 1

0

您必须随时添加每个表格,确保在它们之间留出空间(因为 Word 喜欢组合表格)。

你的循环中需要这样的东西:

* Assumes you start with oDoc pointing to the document,
* oRange set to an empty range at the beginning of the area where you want to add the tables, 
* and that nRows and nCols give you the size of the table.

oTable = oDoc.Tables.Add(m.oRange, m.nRows, m.nCols)
oRange = oTable.Range()
oRange.Collapse(0)
oRange.InsertParagraphAfter()
oRange.Collapse(0)

在此代码之后,您可以使用 oTable 添加您要添加​​的数据。然后,在下一次循环中,您可以在刚刚填写的表格下方添加另一个表格。

于 2014-07-25T20:50:36.863 回答