Thread: [Solved] Word GoTo From Excel
View Single Post
 
Old 12-04-2012, 02:35 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

Hi Matt,

If you're simply updating a bookmarked range, there is no need for the GoTo - simply address the range:
Code:
    Dim wrdApp As Word.Application
    Dim wrdDoc As Word.Document, WrdRng As Word.Range
    Dim i As Integer
    Set wrdApp = CreateObject("Word.Application")
    wrdApp.Visible = True
    Set wrdDoc = wrdApp.Documents.Open(directory)
    With wrdDoc
        If .Bookmarks.Exists("g") Then
            Set WrdRng = .Bookmarks("g").Range
            .Tables.Add Range:=WrdRng, NumRows:=2, NumColumns:=2
            ' Reapply the bookmark to the table
            .Bookmarks.Add Name:="g", Range:=WrdRng
        End If
     End With
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote