Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-02-2021, 11:17 PM
karkey karkey is offline need to find Windows 10 need to find Office 2013
Novice
need to find
 
Join Date: Jan 2021
Posts: 19
karkey is on a distinguished road
Default need to find


I need to find and highlight paragraphs without this character "<" at the start of a paragraph
Reply With Quote
  #2  
Old 01-03-2021, 03:55 AM
eduzs eduzs is offline need to find Windows 10 need to find Office 2019
Expert
 
Join Date: May 2017
Posts: 262
eduzs is on a distinguished road
Default

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
__________________
Backup your original file before doing any modification.
Reply With Quote
  #3  
Old 01-03-2021, 04:16 AM
karkey karkey is offline need to find Windows 10 need to find Office 2013
Novice
need to find
 
Join Date: Jan 2021
Posts: 19
karkey is on a distinguished road
Default

eduzs Thanks a lot.
Reply With Quote
  #4  
Old 01-03-2021, 06:27 AM
gmaxey gmaxey is offline need to find Windows 10 need to find Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,428
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

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
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #5  
Old 01-03-2021, 06:32 AM
eduzs eduzs is offline need to find Windows 10 need to find Office 2019
Expert
 
Join Date: May 2017
Posts: 262
eduzs is on a distinguished road
Default

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
__________________
Backup your original file before doing any modification.
Reply With Quote
  #6  
Old 01-03-2021, 06:33 AM
gmaxey gmaxey is offline need to find Windows 10 need to find Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,428
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

eduzs,



Now you do and somebody probably knows how to do it better. That is the beauty of VBA. Never ending learning process.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
need to find 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
need to find Find what box in Find and replace limits the length of a search term Hoxton118 Word VBA 7 06-10-2014 05:05 AM
need to find Bad view when using Find and Find & Replace - Word places found string on top line paulkaye Word 4 12-06-2011 11:05 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:18 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft