Bookmark in a Text Box in Word

johncallaghan

Registered User.
Local time
Today, 02:27
Joined
Sep 12, 2005
Messages
40
I am inserting data from Access into Word.

This code has been working fine for the last five years but when the bookmark is in a textbox it passes the first test and determines that the bookmark exists but on the next line it tells me 'cannot find requested bookmark'.

MSObjDoc is a Public Variable for the ActiveDocument.

Any explanation would be welcome.

Public Sub InsertText(BookMk As String, TextToInsert As String)
Dim WordRange As Word.Range
If MsObjDoc.Bookmarks.Exists(BookMk) Then ' Passes this statement OK)
Set WordRange = MsObjDoc.GoTo(What:=wdGoToBookmark, name:=BookMk) ' (Error on this line)
WordRange.InsertAfter TextToInsert
End If
End Sub
 

Users who are viewing this thread

Back
Top Bottom