True. ActiveDocument.Tables(1) points to the first table in the document. Selection.Tables(1) points to the first table in the Range object of the selection. It returns an run-time error if there is no table in the selected range. As does ActiveDocument.Tables(1) if there are no tables.
If possible it better to avoid making Selections. It is better to use Range objects where ever possible. Using Bookmarks is a very good way to get chunks of a document and doing stuff with them. All bookmarks have a range (they are in fact ranges) Start and End. You can use these.
Say you have a document with a bunch of tables grouped together. Lots of text, then a bunch of tables, then a lot more text.
Set a bookmark ("TablesStart") at the start of the table area. Set another at the end ("TablesEnd"). You can put as much other stuff between these, or outside as you like.
To process all the tables, regardless of what page they are on, between the bookmarks and ONLY that range, you set a range:
Code:
Dim aDoc as Document
Dim r As Range
Dim mTable As Table
Set aDoc = ActiveDocument
Set r = aDoc.Range(Start:= _
aDoc.Bookmarks("TablesStart").End, _
End:= aDoc.Bookmarks("TablesEnd").Start)
For Each mTable In r.Tables()
mTable.Rows(1).Cells(2).Range.Text = "whatever"
Next
Set r = Nothing
Set aDoc = Nothing
By explicitly creating a Range, you can process within that range - this could leave other tables alone, or whatever. Nothing is ever Selected, so it is not visible to the user, and could in fact be run in the background on a document the user never even sees.
Gerry