find highlighted in VBA

Soldato
Joined
26 Aug 2004
Posts
7,571
Location
London
I don't know how useful this will be for anyone else, but I thought I'd share it anyway.

I'm often reading through cases and highlighting important sentences so that I can easily find them again. It's quite usual that all I'll later need is those key highlighted sentences. I thus thought a macro which moved a copy of all the highlighted sentences onto the first page - almost as a summary - would be useful. Below is the vba code I came up with

Code:
Public Sub findhighlighted()

Selection.WholeStory
Selection.Copy
Selection.Find.ClearFormatting

With Selection.Find
    .Replacement.ClearFormatting
    .Text = ""
    .Highlight = False
    .Replacement.Text = "" & Chr(13) & Chr(13)
    .Execute Replace:=wdReplaceAll
End With
ActiveDocument.Characters.Last.Select
Selection.Collapse
Selection.InsertBreak Type:=wdLineBreak
Selection.InsertBreak Type:=wdPageBreak
Selection.PasteAndFormat (wdPasteDefault)
End Sub

Hope someone finds it as useful as I have done.
 
Back
Top Bottom