W
wZrokowiec
I have a wonderful macro in Microsoft Word 2003 that I'm happy with
and I've used for many years but now .. I need a small modification.
The macro finds a given string of characters and removes the
paragraphs which encompass them. So far so good. But now I'd like the
macro NOT TO remove but to highlight the paragraphs with RED or GREEN
color. The procedure is as follows: --> find all the paragraphs with
"abcdef.." string of characters and change the color of the paragraph
(or the letters) to red/green.
Of course the strings of characters are given in a table in a separate
file (let's say 'c:/aaaaaa.com')
Is it an easy task to change it?
Here is the macro:
Sub xxx()
Dim Source As Document
Dim Ads As Document
Dim Signature As Range
Dim i As Long
Dim drange As Range
Set Ads = ActiveDocument
Set Source = Documents.Open("C:\Signatures.doc")
Ads.Activate
For i = 2 To Source.Tables(1).Rows.Count
Set Signature = Source.Tables(1).Cell(i, 1).Range
Signature.End = Signature.End - 1
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:=Signature.Text,
MatchWildcards:=False, _
Wrap:=wdFindContinue, Forward:=True) = True
Set drange = Selection.Paragraphs(1).Range
drange.Delete
Loop
End With
Next i
End Sub
Sincerely Yours
wZ
and I've used for many years but now .. I need a small modification.
The macro finds a given string of characters and removes the
paragraphs which encompass them. So far so good. But now I'd like the
macro NOT TO remove but to highlight the paragraphs with RED or GREEN
color. The procedure is as follows: --> find all the paragraphs with
"abcdef.." string of characters and change the color of the paragraph
(or the letters) to red/green.
Of course the strings of characters are given in a table in a separate
file (let's say 'c:/aaaaaa.com')
Is it an easy task to change it?
Here is the macro:
Sub xxx()
Dim Source As Document
Dim Ads As Document
Dim Signature As Range
Dim i As Long
Dim drange As Range
Set Ads = ActiveDocument
Set Source = Documents.Open("C:\Signatures.doc")
Ads.Activate
For i = 2 To Source.Tables(1).Rows.Count
Set Signature = Source.Tables(1).Cell(i, 1).Range
Signature.End = Signature.End - 1
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:=Signature.Text,
MatchWildcards:=False, _
Wrap:=wdFindContinue, Forward:=True) = True
Set drange = Selection.Paragraphs(1).Range
drange.Delete
Loop
End With
Next i
End Sub
Sincerely Yours
wZ