![]() |
|
#1
|
|||
|
|||
|
I need to find and highlight paragraphs without this character "<" at the start of a paragraph
|
|
#2
|
|||
|
|||
|
Try:
Code:
Sub test()
Dim oPara As Paragraph
For Each oPara In ActiveDocument.Paragraphs
If oPara.Range.Characters(1) <> "<" Then oPara.Range.HighlightColorIndex = wdYellow
Next oPara
End Sub
|
|
#3
|
|||
|
|||
|
eduzs Thanks a lot.
|
|
#4
|
|||
|
|||
|
Karkey/eduzs
For Each Loops in VBA can start to bog down very quickly in long documents. Better to first find what you are looking for then apply processes: Sub ScratchMacro() 'A basic Word macro coded by Greg Maxey Dim oRng As Range Set oRng = ActiveDocument.Range oRng.InsertBefore vbCr With oRng.Find .Text = Chr(13) & "<" While .Execute oRng.Paragraphs(2).Range.HighlightColorIndex = wdBrightGreen Wend End With ActiveDocument.Range.Paragraphs(1).Range.Delete lbl_Exit: Exit Sub End Sub |
|
#5
|
|||
|
|||
|
I figured it would be possible to do it with find, but didn't know about this problem and how to do with find.
Thanks gmaxey |
|
#6
|
|||
|
|||
|
eduzs,
Now you do and somebody probably knows how to do it better. That is the beauty of VBA. Never ending learning process. |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Range method Find can't find dates
|
jmcsa3 | Excel Programming | 1 | 05-02-2020 06:56 AM |
| How do you use the find and replace tool to find dates and times in Excel 2013? | Jules90 | Excel | 3 | 04-14-2020 07:40 PM |
| find IP in range / find number between numbers | gn28 | Excel | 4 | 06-14-2015 03:46 PM |
Find what box in Find and replace limits the length of a search term
|
Hoxton118 | Word VBA | 7 | 06-10-2014 05:05 AM |
Bad view when using Find and Find & Replace - Word places found string on top line
|
paulkaye | Word | 4 | 12-06-2011 11:05 PM |