views:

131

answers:

1

I have a bunch of documents that need to be edited. The authors use blue text in some parts of the documents to indicate that those words need to be linked.

Thank you cornelius for the highlight text code:

Sub HighlightNotBlack()
    Dim char As Range

For Each char In ActiveDocument.Characters
If char.Font.Color <> wdColorAutomatic And char.Font.Color <> wdColorBlack Then
    char.HighlightColorIndex = wdYellow
End If
Next
End Sub

I would like to expand on this question. Is it possible to extract out only the highlighted text into a new word file? It should also be smart enough to know that two or more consecutive words in a sentence would all appear on one line in the new document as opposed to each word getting its own line in the new document. I figure it could look for all highlighted selections and only bring those over since the whole block of text would be entirely highlighted

+1  A: 

I came with something like this. It highlights all non-black and non-automatic characters in active document.

Sub HighlightNotBlack()
Dim char As Range

For Each char In ActiveDocument.Characters
    If char.Font.Color <> wdColorAutomatic And char.Font.Color <> wdColorBlack Then
        char.HighlightColorIndex = wdYellow
    End If
Next
End Sub
Cornelius
Thanks for your help!I was wondering if you knew how to also make it ignore hyperlinked text.Ultimately, It'd be great to have a macro that extracted the highlighted words into a separate file with each highlighted selection on its own line in the file.I might be asking for too much, but would be great to expand on this!
Vlad