D
David Beamish
I am creating Word documents with lots of clickable hyperlinks (mostly
internal cross-references, table of contents, etc.) and I want to colour
the hyperlinks so that they are easily visible on-screen. I tried a
macro on these lines:
Dim oField As Field
For Each oField In ActiveDocument.Fields
If oField.Type = wdFieldHyperlink Or oField.Type = wdFieldRef _
Or oField.Type = wdFieldPageRef Then
oField.Result.Font.Color = wdColorBlue
End If
Next oField
The problem is that this affects only the part of the field within the
curly brackets, and when the field is updated the formatting disappears.
I can get round it like this:
Dim oField As Field
For Each oField In ActiveDocument.Fields
If oField.Type = wdFieldHyperlink Or oField.Type = wdFieldRef _
Or oField.Type = wdFieldPageRef Then
oField.Select
Selection.Font.Color = wdColorBlue
End If
Next oField
But this is much slower and seems rather inelegant. Does anyone know any
way in VBA of operating on a range which includes the whole of a field,
curly brackets and all, other than selecting it?
internal cross-references, table of contents, etc.) and I want to colour
the hyperlinks so that they are easily visible on-screen. I tried a
macro on these lines:
Dim oField As Field
For Each oField In ActiveDocument.Fields
If oField.Type = wdFieldHyperlink Or oField.Type = wdFieldRef _
Or oField.Type = wdFieldPageRef Then
oField.Result.Font.Color = wdColorBlue
End If
Next oField
The problem is that this affects only the part of the field within the
curly brackets, and when the field is updated the formatting disappears.
I can get round it like this:
Dim oField As Field
For Each oField In ActiveDocument.Fields
If oField.Type = wdFieldHyperlink Or oField.Type = wdFieldRef _
Or oField.Type = wdFieldPageRef Then
oField.Select
Selection.Font.Color = wdColorBlue
End If
Next oField
But this is much slower and seems rather inelegant. Does anyone know any
way in VBA of operating on a range which includes the whole of a field,
curly brackets and all, other than selecting it?