Captions aren't properties of table objects, they're just text. You could do something like this for finding table captions, though:
$style = $doc.Styles | ? { $_.NameLocal -eq 'Caption' }
$wd.Selection.Find.Style = $style
$wd.Selection.Find.Text = 'Table' # if table captions are labeled "Table"
$wd.Selection.Find.Execute()
Since wildcard matches are non-greedy in Word, you may have to do something like this:
$style = $doc.Styles | ? { $_.NameLocal -eq 'Caption' }
$wd.Selection.Find.Style = $style
$wd.Selection.Find.Wrap = 0
while ($wd.Selection.Find.Execute()) {
if ($wd.Selection.Text -like 'Table*') {
# do stuff
}
$wd.Selection.MoveRight()
}
The above matches just by style, so it should select the entire caption. The MoveRight()
unselects the caption afterwards, so the next iteration will find the next match until the end of the document, where the search stops (.Find.Wrap = 0
).