
Signature
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.
Hope this helps,
Doug Robbins - Word MVP
Doug,
Yes, interesting. I couldn't find a way around it and opted to use the
formfield name instead of the index.
http://word.mvps.org/FAQs/TblsFldsFms/GetCurFmFldName.htm

Signature
Greg Maxey/Word MVP
A Peer in Peer to Peer Support
> Hi Greg,
>
[quoted text clipped - 27 lines]
>> Greg Maxey/Word MVP
>> A Peer in Peer to Peer Support
Tony Jollans - 27 Feb 2005 12:11 GMT
There are (at least) two issues here.
Firstly, whatever happens when selecting via the GUI, this is clearly a bug,
Range(0, 100).Bookmarks, say, does NOT contain a bookmark which starts at 110
and it is wrong that such a bookmark is included in the Count.
Knowing that this is what happens, however, at least means that code can be
written to handle the situation. HOWEVER, your basic logic is flawed because
Bookmarks(3), say, is not necessarily the third bookmark from the start of
the document; they just aren't numbered that way.
Enjoy,
Tony
> Doug,
>
[quoted text clipped - 33 lines]
> >> Greg Maxey/Word MVP
> >> A Peer in Peer to Peer Support
Tony Jollans - 27 Feb 2005 23:49 GMT
Apologies, before someone else corrects me! Bookmarks in a Document aren't
numbered sequentially, but bookmarks in a Range are, so here's an amendment
to your code to work round Word's peculiarity:
Dim oDoc As Document
Set oDoc = ActiveDocument
oDoc.Variables("Index").Value = _
oDoc.Range(0, Selection.Bookmarks(1).Range.End).Bookmarks.Count
Dim i As Long
For i = oDoc.Variables("Index").Value To 1 Step -1
If oDoc.Range(0, Selection.Bookmarks(1).Range.End).Bookmarks(i).Start >
Selection.End Then
oDoc.Variables("Index").Value = oDoc.Variables("Index").Value - 1
Else
Exit For
End If
Next
MsgBox oDoc.Variables("Index").Value
> Doug,
>
[quoted text clipped - 33 lines]
> >> Greg Maxey/Word MVP
> >> A Peer in Peer to Peer Support