Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-30-2012, 08:42 AM
mpdsal mpdsal is offline Help with VBA code to find and highlight text Windows XP Help with VBA code to find and highlight text Office 2007
Novice
Help with VBA code to find and highlight text
 
Join Date: Nov 2011
Posts: 19
mpdsal is on a distinguished road
Default


It would be a sentence in this case. I can select the text I want hightlighted manually by moving the cursor to that row and pressing shift End. That selects the entire text string I would like to highlight. Problem is when I record that and insert the code in my macro when it loops through the logic again the new serach string includes all the text which is selected instead of just "Procedure Step:" as it should. Hope this helps.

Thanks
Reply With Quote
  #2  
Old 10-30-2012, 10:15 AM
mpdsal mpdsal is offline Help with VBA code to find and highlight text Windows XP Help with VBA code to find and highlight text Office 2007
Novice
Help with VBA code to find and highlight text
 
Join Date: Nov 2011
Posts: 19
mpdsal is on a distinguished road
Default

I think I got it. It may be crude but it works. I think within a week or two I can be an MPV.

Code:
Sub Highlight_WordN()
Dim sFindText As String
'Start from the top of the document
 Selection.HomeKey wdStory
 
sFindText = "Procedure Step:"
Selection.Find.Execute sFindText
Do Until Selection.Find.Found = False
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
        Selection.Range.HighlightColorIndex = wdYellow
        Selection.MoveRight
        Selection.Find.Execute
Loop
End Sub
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find out the duplicates and highlight them? Learner7 Excel 6 06-08-2017 06:04 AM
Help with VBA code to find and highlight text Find and highlight all words ending in -ly RBLampert Word VBA 13 10-23-2012 04:45 PM
Keyboard shortcut for 'not highlight' in 'Find'? bertietheblue Word 0 05-02-2012 06:16 AM
Highlight text and find next instance DrDOS Word 0 11-15-2010 04:02 PM
find - reading highlight - highlight all / highlight doesn't stick when saved bobk544 Word 3 04-15-2009 03:31 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:25 PM.


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