感谢您查看这个。
我正在尝试将单词表中的值转换为变量。在大多数情况下它可以工作,但在最后一部分我不能。在搜索文本类似于“利息支付日期(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