Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-16-2019, 09:54 PM
subrota subrota is offline Synonym list Windows 10 Synonym list Office 2013
Novice
Synonym list
 
Join Date: Apr 2019
Posts: 11
subrota is on a distinguished road
Default Synonym list

I want all synonyms with a list inside a text box in a user form for a word from a paragraph. But it shows one by one with the msgbox.





Code:
Private Sub CommandButton1_Click()

Dim mySynObj As Object
Dim SList As Variant
Dim i As Variant

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(SList)
  MsgBox "A synonym for " & mySynObj.Word _
   & " is " & SList(i)
Next i
End Sub
Attached Files
File Type: docm Synonym List.docm (16.6 KB, 7 views)

Last edited by macropod; 04-16-2019 at 10:45 PM. Reason: Added code tags & formatting
Reply With Quote
  #2  
Old 04-16-2019, 10:50 PM
macropod's Avatar
macropod macropod is offline Synonym list Windows 7 64bit Synonym list 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's a trivial, change. Really!
Code:
Private Sub CommandButton1_Click()

Dim mySynObj As Object
Dim SList As Variant
Dim i As Long
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
End Sub
PS: When posting code, please use the code tags, indicated by the # button on the posting menu, and structured code. Without both, your code loses much of whatever structure it had.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 04-16-2019, 11:29 PM
subrota subrota is offline Synonym list Windows 10 Synonym list Office 2013
Novice
Synonym list
 
Join Date: Apr 2019
Posts: 11
subrota is on a distinguished road
Default

Thanks a lot Edstein
It works perfectly. Thanks Again.
Reply With Quote
Reply

Tags
synonym list

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Synonym list How to import list from Excel into drop-down list into word ahw Word VBA 43 02-28-2020 08:11 PM
Task list checkboxes appear solid black when I print list mechitar Outlook 0 10-24-2018 09:06 AM
Attempting to mail merge one list into a document containing 3 pages - each page needs the same list LisaRH Mail Merge 3 08-09-2018 03:01 PM
Word 2013 question - master list current list markecb Word 6 02-28-2016 01:51 AM
Synonym list List Style Numbering picks up out of order number from LATER list spthomas Word 12 12-16-2013 05:23 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:45 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