![]() |
|
#1
|
|||
|
|||
|
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
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
|
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| cross-references | gurpreetsandhu | Word | 1 | 06-06-2019 04:13 PM |
| About Cross-references | mohsen.amiri | Word | 1 | 01-19-2017 10:35 AM |
| Convert manual cross references in footnotes to other footnotes to automatic cross references | ghumdinger | Word VBA | 7 | 11-20-2014 11:47 PM |
Cross-References
|
acolussi | Word | 9 | 05-16-2013 02:11 AM |
| Cross References | egcharles | Office | 0 | 04-19-2009 06:20 AM |