![]() |
|
#1
|
|||
|
|||
|
Synonyms Finder in MS Word
Requirements
Example Text to be selected =============== A computer is a device that can be instructed to carry out sequences of arithmetic or logical operations automatically via computer programming. We cannot live without computer The synonyms for the bold/target words are following Target word: computer User defined synonyms: Processor, supercomputer, workstation, CPU MS word synonyms: Processor, microprocessor, motherboard The selection window will display the following (this is one way) Computer • Processor • Microprocessor • Motherboard o Supercomputer o Workstation o CPU After user selection Computer • Processor • Microprocessor o Motherboard o Supercomputer • Workstation o CPU Synonym Code: Code:
Sub Synonyms_List()
Dim mySynObj As Object
Dim SList As Variant
Dim i As Long
Dim StrOut As String
Selection.MoveLeft Unit:=wdWord, Count:=1
Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtend
Set mySynObj = Selection.Range.SynonymInfo
SList = mySynObj.SynonymList(1)
For i = 1 To UBound(mySynObj.SynonymList(1))
StrOut = StrOut & vbCr & SList(i)
Next i
'MsgBox "Synonyms for " & mySynObj.Word & " are:" & StrOut
Dim strClipText As DataObject
Dim strInputText As String
Dim errCode As Integer
Set strClipText = New DataObject
strInputText = StrOut
strClipText.SetText strInputText
strClipText.PutInClipboard
Documents.Add
Selection.PasteAndFormat (wdFormatOriginalFormatting)
End Sub
Code:
Sub target_word()
Selection.HomeKey Unit:=wdStory
' Selection.Find.ClearFormatting
Selection.Find.Font.Bold = True
Selection.Find.Execute
Selection.Copy
Documents.Add 'Template:="Normal", NewTemplate:=False, DocumentType:=0
Selection.PasteAndFormat (wdFormatOriginalFormatting)
Selection.TypeParagraph
windows(2).Activate
' Selection.Find.ClearFormatting
' Selection.Find.Font.Bold = True
Do While Selection.Find.Execute
Selection.Copy
windows(1).Activate
Selection.PasteAndFormat (wdFormatOriginalFormatting)
Selection.TypeParagraph
windows(2).Activate
Loop
End Sub
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Synonym list
|
subrota | Word VBA | 2 | 04-16-2019 11:29 PM |
| Excel Macro: Duplicate Finder | Saucy_Moonbeams | Excel Programming | 0 | 06-18-2018 04:59 AM |
| Using a product key finder to transfer MS from PC to Mac - risky? | loza890 | Office | 1 | 11-02-2014 10:43 PM |
Acronym Finder
|
Cray_Z | Word VBA | 14 | 09-22-2014 11:42 PM |
| Function Finder | Kevin18014 | Excel | 3 | 01-02-2012 04:47 PM |