Bookmark in a text box using VBA
Posted on 2009-02-08
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)