![]() |
|
#1
|
|||
|
|||
|
I currently have a macro that searches for "STOP:" in a table. I would like to also search for "NEXT:" at the same time (want to change the paragraph to red. How can I do this? See current code below. Thanks! Code:
Dim r As Range
Dim Para As Paragraph
Dim aCell As Cell
Dim myTable As Table
'Find all Tip Paragraphs and turn red
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Set myTable = ActiveDocument.Tables(1)
For Each aCell In myTable.Columns(3).Cells
Set r = aCell.Range
For Each Para In aCell.Range.Paragraphs
With Para.Range
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "STOP:"
.Format = True
.Forward = True
.Wrap = wdFindStop
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute
End With
Do While .Find.Found = True
With .Duplicate
If .InRange(r) Then
.Paragraphs.First.Range.Font.Color = wdColorRed
End If
End With
.Collapse wdCollapseEnd
.Find.Execute
Loop
End With
Next
Next
End Sub
|
|
#2
|
||||
|
||||
|
Perhaps something based on:
Code:
Sub Demo()
Application.ScreenUpdating = False
With ActiveDocument.Range.Find
.ClearFormatting
.Text = "STOP:[!^13]@NEXT:"
With .Replacement
.ClearFormatting
.Text = "^&"
.Font.ColorIndex = wdRed
End With
.Forward = True
.Wrap = wdFindStop
.Format = True
.MatchWildcards = True
.Execute Replace:=wdReplaceAll
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Search for date and then apply mutliple search criteria in huge dataset | maxtymo | Excel | 2 | 12-01-2013 04:52 AM |
| 2013 search results take a long time - they fill in as results in reverse date order | themookman | Outlook | 0 | 10-11-2013 12:01 PM |
| Multiple words, one search | return2300 | Word VBA | 0 | 08-30-2013 12:26 PM |
Search for words starting in capitals
|
surreytom | Word VBA | 3 | 04-01-2012 01:41 AM |
Perform a search for alternative words
|
jungkim | Word | 2 | 03-24-2012 07:40 AM |