Find or count all usages of an end note in Microsoft Word

0

I have created a document with end notes in it. I have referred to individual end notes multiple times in the document. How can I either find all usages or preferably count all usages of an end note?

muzzamo

Posted 2013-08-27T05:07:38.963

Reputation: 188

Answers

0

You could see if the following VBA gets you anything close to what you need (it would probably need quite a bit of improvement to deal with all possible reference locations, etc., and to present the output better).

Sub countEndNoteRefs()
Dim bShowHidden As Boolean
Dim eno As Word.Endnote
Dim fld As Word.Field
Dim lCount As Long
Debug.Print "Note", "Refs", "Text"
For Each eno In ActiveDocument.Endnotes
  bShowHidden = eno.Reference.Bookmarks.ShowHidden
  eno.Reference.Bookmarks.ShowHidden = True
  lCount = 0
  If eno.Reference.Bookmarks.Count > 0 Then
    For Each fld In ActiveDocument.Fields
      If fld.Type = Word.WdFieldType.wdFieldNoteRef Then
        If InStr(1, UCase(fld.Code), UCase(eno.Reference.Bookmarks(1).Name)) > 0 Then
          lCount = lCount + 1
        End If
      End If
    Next
  End If
  eno.Reference.Bookmarks.ShowHidden = bShowHidden
  Debug.Print eno.Index, lCount, eno.Range.Text
Next
End Sub

user181946

Posted 2013-08-27T05:07:38.963

Reputation: