【发布时间】:2013-03-13 04:35:31
【问题描述】:
我在 MS Word 中有一个 3 X 3(比如 tableA)表。 第 (2,2) 个单元格是一个拆分单元格(拆分为 2X2 表)。 如何循环遍历 tableA 中的所有单元格。
Dim strCellText As String
Dim uResp As String
Dim Row As Integer
Dim Col As Integer
Dim itable As Table
For Each itable In ThisDocument.Tables
uResp = ""
For Row = 1 To itable.Rows.Count
For Col = 1 To itable.Columns.Count
strCellText = itable.Cell(Row, Col).Range.Text
uResp = uResp & Trim(strCellText)
Next
Next
MsgBox uResp
Next
这个程序给出了编译错误:
Run time error 5914
The requested member of the collection does not exist
如何遍历具有拆分单元格的表格的单元格。
【问题讨论】:
-
哪一行有这个错误?通常,您的代码是正确的,这意味着它会根据需要遍历所有单元格。因此,您的问题出在其他地方,因为我在使用您的代码时没有任何错误。
-
@KazJaw 您是否尝试过使用拆分单元格的表格。
-
对不起,我错过了这一点,所以我再次检查...
标签: vba split ms-word iteration cell