Quote:
Originally Posted by fumei
Code:
Sub CopyHighlightsToOtherDoc()
Dim ThisDoc As Document
Dim ThatDoc As Document
Dim r As Range
Set ThisDoc = ActiveDocument
Set r = ThisDoc.Range
Set ThatDoc = Documents.Add
With r.Find
.Text = ""
.Highlight = True
Do While .Execute(Forward:=True) = True
ThatDoc.Range.InsertAfter r.Text & vbCrLf
r.Collapse 0
Loop
End With
End Sub
All highlighted text in the ActiveDocument are copied (with an added paragraph mark to separate them) to a new document.
|
This is awesome. But I was wondering if you can tweak this for my need. Basically it does the same thing but instead of pasting it in a new document I want it to override the current document. I want nothing else on that document but for the result to be pasted, then save it. This is so that I can keep the result under the same filename.
Thank you.