Log in

View Full Version : [SOLVED:] Clause identifier Macro



Programmer_n
04-18-2016, 08:19 PM
Hi,

Recently, I was thinking of creating a Main clause and subordinate clause highlighter. Although the idea is crude. I want to highlight the sentence preceding ; in green color and sentence succeeding ; till the end of the sentence in say yellow color.

It seems word is able to identify a sentence till the arrival of a full stop.


Sub Macro2()
Selection.MoveRight Unit:=wdSentence, Count:=1, Extend:=wdExtend
End Sub

This code selects the sentences from mouse pointer to till end of a sentence. But it doesn't sense the ;



Sub s()
With Selection
.Extend
.Find.Text = "[;" & "]"
.Find.MatchWildcards = True
.Find.Execute
.Find.Text = "[." & "]"
.Find.Execute
End With
End Sub


Any help please.

gmaxey
04-19-2016, 02:35 AM
It certainly does here.


Sub s()
With Selection
.Extend
.Find.Text = "[;" & "]"
.Find.MatchWildcards = True
.Find.Execute
.Range.HighlightColorIndex = wdBrightGreen
.Collapse wdCollapseEnd
.Find.Text = "[." & "]"
.Find.Execute
.Range.HighlightColorIndex = wdYellow
End With
End Sub

Programmer_n
04-21-2016, 03:50 AM
Thanks.