View Single Post
Old 09-04-2019, 08:30 AM
gmaxey gmaxey is offline Windows 10 Office 2016
Word MVP 2003-2009
Join Date: May 2010
Location: Marble, NC
Posts: 1,033
gmaxey will become famous soon enoughgmaxey will become famous soon enough

Sub ExtractSynonyms()
Dim oSynInfo As Object
Dim varList As Variant
Dim lngIndex As Long, lngSyn As Long
Dim strSyns As String
Dim oDoc As Document, oDocReport As Document
Dim oRng As Range
Dim arrList() As String
  Set oDoc = ActiveDocument
  Set oDocReport = Documents.Add
  Set oRng = oDoc.Range
  arrList = Split("layout|Content|many|Various|sometimes|use", "|")
  For lngIndex = 0 To UBound(arrList)
    Set oRng = oDoc.Range
    With oRng.Find
      .Text = arrList(lngIndex)
      .Font.Bold = True
      .MatchCase = True
      If .Execute Then
        strSyns = arrList(lngIndex) & " - "
        Set oSynInfo = oRng.SynonymInfo
        varList = oSynInfo.SynonymList(1)
        For lngSyn = 1 To UBound(oSynInfo.SynonymList(1))
          strSyns = strSyns & " " & varList(lngSyn)
        oRng.Collapse wdCollapseEnd
        oDocReport.Range.InsertAfter strSyns & vbCr & vbCr
      End If
    End With
  Next lngIndex
  Exit Sub
End Sub
Greg Maxey
Please visit my web site at
Reply With Quote