Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-28-2019, 12:14 AM
subrota subrota is offline Synonym Finder Windows 10 Synonym Finder Office 2013
Novice
Synonym Finder
 
Join Date: Apr 2019
Posts: 11
subrota is on a distinguished road
Default Synonym Finder

Synonyms Finder in MS Word
Requirements
  • To be written as MS word 2016 Macros
  • Will find synonyms from the MS word thesaurus and from a user defined thesaurus
  • In MS word, user will select (say with mouse) text having multiple paragraphs
  • In these paragraph there will be target words in bold (or underlined)
  • Based on user action, such as use of a shortcut key, a list of synonyms for each target word will be returned
  • Synonyms will be fetched from two sources 1) user defined 2) MS word resident Thesaurus
  • User defined synonym can come from a simple text file or excel sheet
  • After fetching the synonyms, the macro will return a user selection window, where all the synonyms with respective words will be displayed so that user can select which synonyms ultimately outputted
  • Selection window will display the synonyms for each target word followed by the respective target word
  • Selection window will not show duplicates
  • In the selection window default selection for user defined synonyms is "selected" and default selection for synonym from MS word thesaurus is "unselected". User can alter the selection by mouse click
  • After the user selection, the selected synonyms will be returned, grouped together with their respective target word.
  • Synonyms from the user defined source will be shown at the beginning of each group
  • The output can be return after the selected text
  • Returned synonyms will take care of various forms of the word (this requirement can be deferred for now)

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
Targeted Word Code:
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
Attached Files
File Type: docx SynonymsFinder.docx (17.9 KB, 7 views)
Reply With Quote
  #2  
Old 04-28-2019, 04:15 AM
macropod's Avatar
macropod macropod is offline Synonym Finder Windows 7 64bit Synonym Finder 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

That will be an interesting project for you to undertake...

You might start by reading: https://www.msofficeforums.com/word/...-separate.html
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 04-28-2019, 11:36 PM
subrota subrota is offline Synonym Finder Windows 10 Synonym Finder Office 2013
Novice
Synonym Finder
 
Join Date: Apr 2019
Posts: 11
subrota is on a distinguished road
Default

Thanks Paul,
Yes this is very interesting project. But it very complex to me . Now I am find out the targeted word and find out the synonym of them. But I am stop. Before the all each synonyms need set a checkbox with the opening new document.
Reply With Quote
  #4  
Old 04-29-2019, 12:13 AM
macropod's Avatar
macropod macropod is offline Synonym Finder Windows 7 64bit Synonym Finder 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

Given your extensive list of requirements, I doubt it's something anyone on a free user forum would be undertaking. Such a project would require the investment of considerable time and effort. There are plenty of coding examples here you might draw on for how to implement a userform, automate Excel from Word, and so on. It would also be a good learning exercise.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Synonym Finder 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
Synonym Finder Acronym Finder Cray_Z Word VBA 14 09-22-2014 11:42 PM
Function Finder Kevin18014 Excel 3 01-02-2012 04:47 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:09 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft