You can bookmark the whole table, or just ensure that the bookmark occurs
somewhere inside the table. Then the following code will work:
Dim tbl As Word.Table
Set tbl = myDoc.Bookmarks("myTable").Range.Tables(1)
It's a general principle of Word VBA that the first table (or paragraph, word,
etc.) "in" a range is actually the first one of which any part is in the range.
If you're using this kind of code, though, you should first ensure that there is
such a bookmark and that it does contain (part of) a table:
Dim tbl As Word.Table
If ActiveDocument.Bookmarks.Exists("myTable") Then
If myDoc.Bookmarks("myTable").Range.Tables.Count 0 Then
Set tbl = myDoc.Bookmarks("myTable").Range.Tables(1)
End If
End If
If Not tbl Is Nothing Then
' continue the macro...
On Wed, 26 Dec 2007 18:18:34 -0800, "Eric" wrote:
I'm missing something - how do I refer to this as a table? Bookmark the
entire table? Is this returning a range I can turn into a table?
dim tbl as word.table
set tbl = myDoc.Bookmarks("myTable")
"Helmut Weber" wrote in message
.. .
Hi Eric,
bookmark the table.
alt num 5, insert bookmark.
--
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Vista Small Business, Office XP
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ:
http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.