|
#1
|
|||
|
|||
Macro to highlight only start of line, not past tab spaces (Word 97)
Hi, I've got a macro to highlight the start of each line in my document.
A(tab space here)(tab space here) Text The problem is when there's no text after the tab spaces (when I haven't typed anything else on that line yet), it highlights the whole line, which means when I go on to that line to type, the text I type is highlighted. Is there a way I could get it to not highlight past the tab spaces? Here is my current macro: Sub ReplaceAwithhighlightedtext() With Selection.Find .Text = "A^t" .Forward = True .Wrap = wdFindContinue .Format = True .MatchCase = True .MatchWholeWord = True .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False .Forward = False Do While .Execute Selection.Range.HighlightColorIndex = wdRed Loop End With Application.Run MacroName:="Normal.NewMacros.ClearFindAndReplacePa rameters" End Sub It extends past the tab spaces, which I'm not sure how to fix. |
#2
|
|||
|
|||
Code:
Sub ReplaceAwithhighlightedtext() Dim oRng As Range Set oRng = ActiveDocument.Range With oRng.Find .Text = "A^t" Do While .Execute oRng.HighlightColorIndex = wdRed oRng.Collapse wdCollapseEnd oRng.HighlightColorIndex = wdAuto Loop End With End Sub |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
start a macro with command Line startup switches | Fesazu | Word | 3 | 02-08-2018 12:15 AM |
issue with highlight macro word 2010 | jamesnavoy | Word VBA | 2 | 01-29-2017 08:32 AM |
macro to add brackets to each line and add single quotes to each word in the line | bracketandquotes | Word VBA | 17 | 02-16-2015 03:51 PM |
Macro Question: Need help making a macro to highlight the first word in every sentence | LadyAna | Word | 1 | 12-06-2014 10:39 PM |
Macro to highlight text between 2 points in word 2010 | jsilva1950 | Word VBA | 2 | 04-25-2013 12:21 AM |