Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.word.formatting.longdocs
Jose Durazo
 
Posts: n/a
Default cross-references and hyperlinks

Thanks Doug, this works for everything except page numbers, so I changed the
test for field type to "If aref.Type = wdFieldRef Or aref.Type =
wdFieldPageRef Then". This now works almost perfectly. It also causes a
blue underline on page numbers in my TOC, so I tweaked the code to exclude
any references within the range of the TOC. Here's resulting code that
seems to work well:

Sub FormatCrossReferences()
Dim aref As Field

' TocRangeStart and end will be set to numbers greater
' than -1 if there's a table of contents in the document
' Macro assumes 0 or 1 table of contents
' Macro will not format items within the range of the TOC
Dim TocRangeStart As Integer
TocRangeStart = -1
Dim TocRangeEnd As Integer
TocRangeEnd = -1
Dim TOCCollection As TablesOfContents
Set TOCCollection = ActiveDocument.TablesOfContents
If Not (TOCCollection Is Nothing) Then
Dim TOC As TableOfContents
Set TOC = TOCCollection.Item(1)
TocRangeStart = TOC.Range.Start
TocRangeEnd = TOC.Range.End
End If

For Each aref In ActiveDocument.Fields
If (aref.Type = wdFieldRef Or aref.Type = wdFieldPageRef) _
And (aref.Result.Start TocRangeStart Or TocRangeEnd _
aref.Result.End) Then
With aref.Result.Font
.Color = wdColorBlue
.Underline = wdUnderlineSingle
End With
End If
Next aref
End Sub


 
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I force long hyperlinks to break when using justify? Al Bedo Microsoft Word Help 4 May 20th 23 02:48 AM
Word 2000 - Hyperlinks in footer to TOC with out edit of footer needyourhelp Microsoft Word Help 4 November 16th 05 03:09 PM
word cross references do not update Seb Tables 6 August 22nd 05 05:18 PM
Using cross references and hyperlinks - Word 2000 oded h Microsoft Word Help 0 March 23rd 05 06:39 PM
lose cross references when save as web page Caroline Microsoft Word Help 1 March 21st 05 07:21 AM


All times are GMT +1. The time now is 05:47 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"