感谢您对此进行调查。
我正在尝试将单词表中的值转换为变量。在大多数情况下,它是有效的,但在最后一部分,我做不到。错误出现在下面的这一行中,搜索文本类似于">利息支付日期(t(";retVal = pTable.Cell(oRow.Index+1, 5)
我猜是因为看起来大桌子里面有一张桌子。关于如何在retVal数组中突出显示黄色日期,有什么建议吗?请参阅图像
Public Function GetCellValue(ByRef pTable As Word.Table, ByVal pRow As Long, ByVal otext As String) As Variant
On Error GoTo Err_GetCellValue
Dim procName As String
Dim retVal As Variant
Dim strValue As String
Dim oRow As Variant
Dim oCell As Variant
Dim found As Boolean
Dim DQ As Variant
procName = "basGeneral::GetCellValue()"
found = False
For Each oRow In pTable.Rows
For Each oCell In oRow.Cells
If oCell.Range.Text Like otext Then
If otext Like "*Interest Payment Dates (t)*" Then
retVal = pTable.Cell(oRow.Index+1, 5)
Else
retVal = pTable.Cell(oRow.Index, 3)
End If
retVal = WorksheetFunction.Clean(retVal)
DQ = Chr(34)
If IsNumeric(retVal) Then
retVal = Replace(retVal, DQ, "")
End If
found = True
Exit For
End If
Next oCell
If found = True Then Exit For
Next oRow
用于复制特定数据的Word文件
这是适用于我的解决方案-
引用本文档第x个表中的yth表---thisdocument.Tables(x).Tables(y)
Thisdocument.Tables.Count
可能只给您1,但不给该表中的表计数。像这样-Thisdocument.Tables(1).Tables(2).Cell(2,3).range.Text