View Single Post
 
Old 06-04-2015, 09:50 PM
gmayor's Avatar
gmayor gmayor is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,137
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

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
Reply With Quote