View Single Post
 
Old 01-19-2020, 02:20 PM
Genericname1111 Genericname1111 is offline Windows 7 64bit Office 97-2003
Novice
 
Join Date: Aug 2019
Posts: 17
Genericname1111 is on a distinguished road
Default 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.
Reply With Quote