Thanks for looking into this.
I am trying to get values from word table into variable. For most part it works but for the last part I could not. Error is in this below line after search text is like "Interest Payment Dates (t)"
retVal = pTable.Cell(oRow.Index+1, 5)
my guess is that because it looks like there is a table inside the bigger table. Any suggestion regarding how do I get dates highlighted in yellow into my retVal array? Pls see image
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
This is the solution that worked for me -
To refer to yth table in xth table in thisdocument ---
thisdocument.Tables(x).Tables(y)
Thisdocument.Tables.Count
may give you only 1 but not tables count inside that table.
Like this - Thisdocument.Tables(1).Tables(2).Cell(2,3).range.Text