Reputation: 11
I am getting Outlook email, were the Body contains a Table consisting of several string Labels and associated string Text. I want to extract three Values associated with the respective Label. The first two searchs are one column right of the Label and the last one is one row below the Label. I tried InStr() which works great for retrieving to the right of the Label, but it doesn't seem to work for the Value that is one cell below the Label. Can I use MoveRight and MoveDown from Excel/Work inside the Outlook VBA or use "Range(Rng.Offset(0, 1).Address).Value" and "Range(Rng.Offset(1, 0).Address).Value" to select the Value to the right and below in Outlook VBA. Key point here is that it is a structured table in the email body.
Upvotes: 1
Views: 3450
Reputation: 2278
i have one email with a table that happens to be nested inside another table
that is why Tables(1).Tables(1)
is used
the following code is for exploring the table.
first line highlights the cell in the table, so that you can check if you are referring the correct cell
the second and third lines shows how to get the value of a table cell
do not try to examine any range
object in the watch window or the locals window. it causes outlook to crash. (no idea why)
if you want to explore any attributes of the range
object then copy the email body to msWord. it does not crash when examining the range object
i could not find anything that refers to column headers
Sub aaaaa()
Application.Inspectors(1).WordEditor.Tables(1).Tables(1).Rows(1).Cells(1).Select
stop
Debug.Print Application.Inspectors(1).WordEditor.Tables(1).Tables(2).Rows(3).Cells(4).Range.Text
Debug.Print ActiveDocument.Tables(1).Tables(1).Cell(1, 1).Range.Text
End Sub
Upvotes: 1