M
MC
Would there be a way to keep format from source in this algorithm while I
copy selected highlighted text (in green) from source to a new document?
Your input is much appreciated.
Thanks!
-----------------------------------------------------------------
Sub Summarize()
Dim NewDoc As Document, MainDoc As Document, r As Range
If Documents.Count = 0 Then Exit Sub
Set MainDoc = ActiveDocument
Set NewDoc = Documents.Add
MainDoc.Activate
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
..Text = ""
..Forward = True
..Wrap = wdFindContinue
..Format = False
..Highlight = True
Do While .Execute
Set r = NewDoc.Range
r.Collapse wdCollapseEnd
Select Case Selection.Range.HighlightColorIndex
Case wdBrightGreen
r.Collapse wdCollapseEnd
r.InsertAfter Selection.Range.FormattedText
If Selection.Characters.Last.Text <> vbCr Then _
r.InsertAfter vbCr
r.ParagraphFormat.LeftIndent = 18
r.HighlightColorIndex = wdBrightGreen
End Select
Loop
End With
NewDoc.Activate
End Sub
-----------------------------------------------------------------
copy selected highlighted text (in green) from source to a new document?
Your input is much appreciated.
Thanks!
-----------------------------------------------------------------
Sub Summarize()
Dim NewDoc As Document, MainDoc As Document, r As Range
If Documents.Count = 0 Then Exit Sub
Set MainDoc = ActiveDocument
Set NewDoc = Documents.Add
MainDoc.Activate
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
..Text = ""
..Forward = True
..Wrap = wdFindContinue
..Format = False
..Highlight = True
Do While .Execute
Set r = NewDoc.Range
r.Collapse wdCollapseEnd
Select Case Selection.Range.HighlightColorIndex
Case wdBrightGreen
r.Collapse wdCollapseEnd
r.InsertAfter Selection.Range.FormattedText
If Selection.Characters.Last.Text <> vbCr Then _
r.InsertAfter vbCr
r.ParagraphFormat.LeftIndent = 18
r.HighlightColorIndex = wdBrightGreen
End Select
Loop
End With
NewDoc.Activate
End Sub
-----------------------------------------------------------------