![]() |
|
#2
|
||||
|
||||
|
Instead of looking at the tables, look for the bookmark e.g.
Code:
Sub Macro1()
Dim wdApp As Object
Dim oDoc As Object
Dim oBM As Object
Dim bBM As Boolean
Dim oTable As Object
Const strBookmarkName As String = "MyTable"
On Error Resume Next
Set wdApp = GetObject(, "Word.Application")
If Err Then
Set wdApp = CreateObject("Word.Application")
End If
Set wdDoc = wdApp.Documents.Open("Full path of document")
For Each oBM In oDoc.Bookmarks
If oBM.name = strBookmarkName Then
If oBM.Range.Information(12) Then
Set oTable = oBM.Range.Tables(1)
bBM = True
'do what you want with oTable e.g.
oTable.Range.Select
End If
Exit For
End If
Next oBM
If Not bBM Then MsgBox ("Bookmark '" & strBookmarkName & "' not present in the document.")
lbl_Exit:
Set oBM = Nothing
Set oTable = Nothing
Set oDoc = Nothing
Set wdApp = Nothing
Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
| Tags |
| bookmarks, vba word, word 2010 |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Bookmark Not Showing Bookmark
|
RegAudit | Word | 6 | 03-16-2015 11:08 PM |
Find what box in Find and replace limits the length of a search term
|
Hoxton118 | Word VBA | 7 | 06-10-2014 05:05 AM |
| vba to go to next bookmark | megatronixs | Word VBA | 2 | 06-08-2014 09:53 PM |
Bad view when using Find and Find & Replace - Word places found string on top line
|
paulkaye | Word | 4 | 12-06-2011 11:05 PM |
VBA to insert Bookmark
|
rockwellsba | Word VBA | 2 | 05-31-2011 01:07 AM |