View Single Post
 
Old 09-04-2019, 08:30 AM
gmaxey gmaxey is offline Windows 10 Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,421
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Code:
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)
        Next
        oRng.Collapse wdCollapseEnd
        oDocReport.Range.InsertAfter strSyns & vbCr & vbCr
      End If
    End With
  Next lngIndex
  oDocReport.Activate
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote