Hi hklein,
To add a title programmatically, you could use code like:
Code:
Sub Demo1()
ActiveDocument.Tables(1).Title = "MyTableTitle"
End Sub
However, if you know which table to add the title to programmatically without selecting it, you probably don't need to give it a title.
Alternatively, if you want to add a title to a
selected table, you can do that through the user interface, or with code like:
Code:
Sub Demo2()
If Selection.Information(wdWithInTable) = False Then Exit Sub
Selection.Tables(1).Title = "MyTableTitle"
End Sub
Ultimately, though you'll want to do something programmatically with the titled table, for which you'll need more sophisticated code, like:
Code:
Sub Demo3()
Dim oTbl As Table
For Each oTbl In ActiveDocument.Tables
If oTbl.Title = "MyTableTitle" Then
'Do something with the table
Exit For
End If
Next
End Sub