View Single Post
 
Old 04-24-2019, 04:44 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

You could, of course use an INDEX, in which case, you'd simply add XE fields at each of the found locations. For example:
Code:
Sub IndexParentheses()
Dim StrIdx As String
With ActiveDocument
  With .Range
    With .Find
      .Text = "\(*\)"
      .MatchWildcards = True
      .Execute
    End With
    Do While .Find.Found = True
      StrIdx = Replace(Replace(.Text, ")", Chr(34)), "(", Chr(34))
      .Collapse wdCollapseEnd
      .Fields.Add .Duplicate, wdFieldEmpty, "XE " & StrIdx, False
      .Find.Execute
    Loop
  End With
    .Indexes.Add Range:=.Range.Characters.Last, HeadingSeparator:=wdHeadingSeparatorNone, _
      Type:=wdIndexIndent, RightAlignPageNumbers:=True, NumberOfColumns:=1
End With
End Sub
No bookmarks or cross-references, per se, needed. The Index entries get sorted alphabetically and, if the same entry appears multiple times, grouped.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote