The following macro -
http://www.gmayor.com/installing_macro.htm - will
extract all highlighted text to a new document, each on a separate line and
separated by highlight colour.
Sub ExtractHiLight()
Dim FirstFind As Boolean
Dim rDcm As Range
Dim lClr As Long ' color index
Dim sCol As String
Dim Doc1 As Document
Dim Doc2 As Document
If ActiveDocument.Content.HighlightColorIndex <> 0 Then
Set Doc1 = ActiveDocument
Set Doc2 = Documents.Add
Doc1.Activate
For lClr = 1 To 16
FirstFind = True
Select Case lClr
Case 1
sCol = "Black"
Case 2
sCol = "Blue"
Case 3
sCol = "Turquoise"
Case 4
sCol = "Bright green"
Case 5
sCol = "Pink"
Case 6
sCol = "Red"
Case 7
sCol = "Yellow"
Case 8
sCol = "White"
Case 9
sCol = "Dark blue"
Case 10
sCol = "Teal"
Case 11
sCol = "Green"
Case 12
sCol = "Violet"
Case 13
sCol = "Dark red"
Case 14
sCol = "Dark yellow"
Case 15
sCol = "50% gray"
Case 16
sCol = "25% gray"
End Select
Set rDcm = Doc1.Range
With rDcm.Find
.Highlight = True
While .Execute
If rDcm.HighlightColorIndex = lClr Then
If FirstFind Then
Doc2.Range.InsertAfter sCol & vbCr
FirstFind = False
End If
Doc2.Range.InsertAfter vbTab & rDcm.Text & vbCr
End If
Wend
End With
Next
Else
MsgBox "No Highlighting found."
End If
End Sub
If you are not bothered about the colours, you can simplify that to
Sub ExtractHiLight()
Dim rDcm As Range
Dim lClr As Long ' color index
Dim Doc1 As Document
Dim Doc2 As Document
If ActiveDocument.Content.HighlightColorIndex <> 0 Then
Set Doc1 = ActiveDocument
Set Doc2 = Documents.Add
Doc1.Activate
Set rDcm = Doc1.Range
With rDcm.Find
.Highlight = True
While .Execute
Doc2.Range.InsertAfter rDcm.Text & vbCr
Wend
End With
Else
MsgBox "No Highlighting found."
End If
End Sub
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site
www.gmayor.com
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>