BookmarkID problem

S

Smallweed

When I run the following I get a "requested member of the collection does not
exist" error:

If Selection.BookmarkID <> 0 Then
MsgBox ActiveDocument.Bookmarks(Selection.BookmarkID).Name
End If

It's because the id of the bookmark enclosing my cursor happens to be 13 and
yet the ActiveDocument.Bookmarks.Count is only 11.

How can this be??
 
P

Pesach Shelnitz

Hi,

I have reproduced the behavior that you observed by adding a table of
contents (TOC) to a document, and I am seeing that the value of BookmarkID is
incremented by 1 for each heading that precedes the bookmark and is included
in the TOC. Do you have a TOC in your document?
 
J

Jean-Guy Marcil

Smallweed was telling us:
Smallweed nous racontait que :
When I run the following I get a "requested member of the collection
does not exist" error:

If Selection.BookmarkID <> 0 Then
MsgBox ActiveDocument.Bookmarks(Selection.BookmarkID).Name
End If

It's because the id of the bookmark enclosing my cursor happens to be
13 and yet the ActiveDocument.Bookmarks.Count is only 11.

How can this be??

You have posted the same message at least three times, please, ne patient,
somebody will eventually answer... Also, note that depending on the
interface you are using to post, it may take a little while for the message
to appear.
 
S

Smallweed

Thanks Jean-Guy: that's the solution I need.

Yeah apologies re multiple posts: I kept getting m/soft errors like "Service
Temporarily Unavailable please try again later" and "an error occurred while
sending your post and your post was not received" and didn't realise they
were lying...

I'll probably get the same when I click Post now!
 

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