Thread: [Solved] VBA find or name a Table
View Single Post
 
Old 01-17-2011, 02:18 PM
macropod's Avatar
macropod macropod is online now Windows 7 32bit Office 2000
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,371
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi smed,

If you bookmark the table, you can find the first table in the bookmarked range. For example:
Code:
celltext = ActiveDocument.Bookmarks("Table1").Range.Tables(1).Cell(1, 1).Range.Text
Do note, though, that specifying 'Cell(1, 1).Range.Text' picks up the end-of-cell marker. To get just the cell's text range, use something like:
Code:
Dim CelRng As Range
Set CelRng = ActiveDocument.Bookmarks("Table1").Range.Tables(1).Cell(1, 1).Range
CelRng.End = CelRng.End - 1
celltext = CelRng.Text
To bookmark a table, you don't need to select the whole table. You can simply bookmark any of the end-of-row markers.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]

Last edited by macropod; 01-17-2011 at 07:25 PM.
Reply With Quote