Bookmark hell (at least for me)

D

Debra Farnham

Hi again all

I'm stumped once again

Win2k Word2K

How can I programatically obtain the name of the previous bookmark ?
Previous meaning the first one that exists above where my insertion point is
presently sitting.

Thanks in advance for any help.

Debra
 
A

Andrew Savikas

MsgBox Selection.Document.Bookmarks(Selection.PreviousBookmarkID).Nam

HT
Andre

----- Debra Farnham wrote: ----

Hi again al

I'm stumped once agai

Win2k Word2

How can I programatically obtain the name of the previous bookmark
Previous meaning the first one that exists above where my insertion point i
presently sitting

Thanks in advance for any help

Debr
 
D

Debra Farnham

Hi Andrew

I've run into a snag

I tested your code and it's returning the name of the bookmark that is
located two bookmarks above my insertion point. Any idea what would be
causing that?

Thanks

Deb
 
D

Doug Robbins - Word MVP

See if this returns the right name

Dim myrange As Range, j As Long
Set myrange = ActiveDocument.Range
myrange.End = Selection.Range.End
If Selection.Bookmarks.Count > 0 Then
j = myrange.Bookmarks.Count - 1
Else
j = myrange.Bookmarks.Count
End If
MsgBox myrange.Bookmarks(j).Name


--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
D

Debra Farnham

It most certainly does work Doug!

Thank you soooo much!

I can finally get some sleep *S*

Deb
 
A

Andrew Savikas

Is the insertion point anywhere inside the nearest bookmark? I'll see if I can replicate the error

----- Debra Farnham wrote: ----

Hi Andre

I've run into a sna

I tested your code and it's returning the name of the bookmark that i
located two bookmarks above my insertion point. Any idea what would b
causing that

Thank

De
 
A

Andrew Savikas

Wow, that PreviousBookmarkID property sure didn't work the way it was supposed to when I did some experimenting

Sorry to have steered you wrong (I've never used that property before), but it looks like Mr. Robbin's got you back on the right track.
 

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