Thread: [Solved] Word GoTo From Excel
View Single Post
 
Old 12-04-2012, 04:27 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
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

It seems, then, your code should be structured along the lines of:
Code:
    With wrdDoc
        If .Bookmarks.Exists("g") Then
            With .Bookmarks("g").Range
                If .Tables.Count > 0 Then
                    With .Tables(1)
                      ' Do whatever you need to with the table
                    End With
                Else
                  ' Do whatever you need to if the table doesn't exist
                End If
            End With
        Else
          ' Do whatever you need to if the bookmark doesn't exist
        End If
     End With
What isn't clear, though, is how you're going to determine where to add the table in the absence of the bookmark, which you appear to suggest could be the case.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote