I have been working with some code to highlight the number after any clause, paragraph, part or schedule references but this only highlights the number immediately following the word (see ref1).
Ref 1.JPG
Code:
StrFndA = "[Aa]rticle,[Aa]ppendix,[Cc]lause,[Pp]aragraph,[Pp]art,[Ss]chedule" 'highlight numbers after these words
For Each Rng In ActiveDocument.StoryRanges
With Rng
Select Case .StoryType
Case wdMainTextStory, wdFootnotesStory
For i = 0 To UBound(Split(StrFndA, ","))
With .Duplicate
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = True
.text = Split(StrFndA, ",")(i) & "[s ^s]@[0-9.]{1,}"
End With
Do While .Find.Execute
.MoveStart wdWord, 1
.HighlightColorIndex = wdTurquoise
.Collapse wdCollapseEnd
Loop
End With
Next
I am trying to expand the code to include any additional cross reference numbers that may follow a comma or the words 'or', 'and', 'and/or'.
At the moment I'm using the following code to try to capture the rest of the manual cross reference numbers which as you can see is not highlighting all the references and I wondered if there was a more efficient way of highlighting the additional references numbers.
Ref 2.JPG
Code:
.text = "([0-9]@{1,}.[0-9]{1,})" 'Highlight manual cross refs separated by period
.Replacement.text = ""
.Execute Replace:=wdReplaceAll
.text = "([0-9]@{1,}.[0-9]{1,}.[0-9]{1,})"
.Replacement.text = ""
.Execute Replace:=wdReplaceAll
.text = "([0-9]@{1,}.[0-9]{1,}.[0-9]{1,}.[0-9]{1,})"
.Replacement.text = ""
.Execute Replace:=wdReplaceAll
Would appreciate any advice given.