![]() |
|
#1
|
|||
|
|||
|
Sub NonBreakSpace()
Application.ScreenUpdating = False Options.DefaultHighlightColorIndex = wdTurquoise Selection.Find.Replacement.Highlight = True Dim StrFR As String, i As Long StrFR = "[<(et)> <(al)>]|\1^s\2" With ActiveDocument.Range.Find .ClearFormatting .Replacement.ClearFormatting .Forward = True .Wrap = wdFindStop .Format = True .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True .Replacement.Highlight = wdTurquoise For i = 0 To UBound(Split(StrFR, "|")) Step 2 .text = Split(StrFR, "|")(i) .Replacement.text = Split(StrFR, "|")(i + 1) .Execute Replace:=wdReplaceAll Next End With Application.ScreenUpdating = True End Sub |
|
#2
|
||||
|
||||
|
You don't need the loop
Code:
Sub NonBreakSpace()
Const strFR As String = "<(et)> <(al)>|\1^s\2"
Dim i As Long
Options.DefaultHighlightColorIndex = wdTurquoise
With ActiveDocument.Range.Find
.ClearFormatting
.Replacement.ClearFormatting
.Replacement.Highlight = True
.Text = strFR
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = True
.Text = Split(strFR, "|")(0)
.Replacement.Text = Split(strFR, "|")(1)
.Execute Replace:=wdReplaceAll
End With
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| I want to highlight specific weeks in the Gantt Chart view but they should be working hours | PL@plan | Project | 1 | 05-05-2021 12:23 PM |
| highlight bar | freeriding | Project | 0 | 12-07-2018 05:25 AM |
| Tasks Switch to Non-Working Days on Working Calendar | danelloc | Project | 3 | 10-02-2017 12:38 PM |
Ugghhh....Highlight Text not working
|
mrayncrental | Word VBA | 1 | 02-10-2014 10:58 PM |
| find - reading highlight - highlight all / highlight doesn't stick when saved | bobk544 | Word | 3 | 04-15-2009 03:31 PM |