Disappearing bookmarks

B

bluecraby2k

I have a procedure that updates the text in bookmarks as follows:
---------------------------------------------------------------------------------------------------------
Public Sub BookMark_Update(strBookMark As String, strText As String)
Dim oRange As Range

On Error GoTo BookMark_Update_Error

With ActiveDocument
Set oRange = .Bookmarks(strBookMark).Range
oRange.Text = strText
.Bookmarks.Add strBookMark, oRange
End With

BookMark_Update_Exit:

On Error GoTo 0
Exit Sub

BookMark_Update_Error:

[error routine]
Resume BookMark_Update_Exit

End Sub

------------------------------------------------------------------------------------------------------------
I use this to insert or update all the bookmarks in my document.
However, I am having a problem with one bookmark. After I insert the
text ok in this bookmark, and I try to refer to it again, I get the
error message that this bookmark does not exist. If I look for the
bookmarks in the document ( Insert->bookmarks), I can see the name of
this particular bookmark. If I look in the Visual Basic IDE, and look
at ThisDocuments.BookMarks, I cannot see this bookmark, but I see all
the other bookmarks. The only difference between this particular
bookmark and the other bookmarks in the document is that this
particular bookmark is very lengthy and contains tab values. I am
trying to refer to this particular bookmark to create table to contains
this bookmark's contents. I have this same procedure in other
documents. As a matter of fact, I just copied the whole code from
another document, that does work.
 
J

Jezebel

Can't see what's going wrong with your code; but an easier way to put
information into a document (and more reliable!) is to use document
properties and DocProperty fields.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top