![]() |
|
#1
|
||||
|
||||
![]()
The following macro will put all the unique highlighted words or phrases into a new document each to a new line:
Code:
Sub ExtractWords() Dim oDoc As Document Dim oSource As Document Dim oRng As Range Dim Coll As Collection Dim i As Long Set oSource = ActiveDocument Set oRng = oSource.Range Set Coll = New Collection With oRng.Find .Highlight = True Do While .Execute On Error Resume Next Coll.Add oRng.Text, oRng.Text oRng.Collapse 0 Loop End With If Coll.Count > 0 Then Set oDoc = Documents.Add For i = 1 To Coll.Count oDoc.Range.InsertAfter Coll(i) & vbCr Next i End If lbl_Exit: Set oDoc = Nothing Set oSource = Nothing Set oRng = Nothing Set Coll = Nothing Exit Sub End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#2
|
|||
|
|||
![]()
Wow, thank you so much! Works like a charm. I really appreciate the help.
Cheers! |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to find (highlight) two and more words in a list of 75k single words in Word 2010 | Usora | Word | 8 | 05-29-2018 03:34 AM |
![]() |
Kalü | Word VBA | 22 | 04-24-2018 05:35 AM |
Highlighted folders | grjbyfleet | Outlook | 0 | 06-03-2017 01:07 AM |
![]() |
thudangky | Word | 13 | 12-12-2013 02:22 AM |
Why Words doesn’t show the style of the selected words automatically???? | Jamal NUMAN | Word | 0 | 04-14-2011 03:20 PM |