I need to run a function on all EndNotes in a specific bookmark in my document, and I am using the following stripped down code: Code:
Dim noteCount as integerDim eNote as EndNotenoteCount = oBookmark.Range.EndNotes.Count Debug.Print "Bookmark " & oBookmark.name & " has " & CStr(noteCount) & " EndNotes." if (noteCount > 0) Then For Each eNote in oBookmark.Range.Endnotes Debug.Print "EndNote #" & eNote.index Next eNoteend if
When I run this on one of the bookmarks in my document, I get the correct NoteCount (e.g. 7), but the loop runs through
ALL of the EndNotes in the document (e.g. I get 42 lines of 'EndNote #X')
Is this a bug, the fact that
oBookmark.Range.EndNotes.Count lists 7, but when I loop through the
oBookmark.Range.EndNotes collection, I get 42 EndNotes, or is there an error in my code? If this is a bug, is there something I can do to work around this? I tried to check
eNote.Range.Bookmarks and
eNote.Range.BookmarkID to verify that the EndNote belongs to the current bookmark, but I'm getting a '0' for both
eNote.Range.BookmarkID &
eNote.Range.Bookmarks.Count
I'm running Word 2007, if that matters.