View Single Post
 
Old 05-10-2013, 03:02 PM
fumei fumei is offline Windows 7 64bit Office XP
Expert
 
Join Date: Jan 2013
Posts: 440
fumei is on a distinguished road
Default

Well if all you want to do is action the bookmarks, then just action the bookmarks. There is no need to select anything.

Code:
Sub HighlightBM_InTable()
Dim BM As Bookmark
For Each BM In Selection.Tables(1).Range.Bookmarks
   BM.Range.HighlightColorIndex = wdBlue
Next
End Sub
The code highlights the bookmarks - and only the bookmarks - in the table the selection is in. If you want to do all tables, there is no need to see if the selection is in a table. No selection is made at all.
Code:
Sub HighlightBM_InTable()
Dim BM As Bookmark
Dim oTable As Table
For Each oTable in ActiveDocument.Tables()
  For Each BM In oTable.Range.Bookmarks
    BM.Range.HighlightColorIndex = wdBlue
  Next
Next
End Sub
Reply With Quote