Macro to navigate to next CR from present location
I have Googled and found nothing. ChatGPT offered me this:
Sub JumpToNextCrossReference()
Dim rng As Range
Dim fld As Field
' Define the range to search for cross-references
Set rng = Selection.Range
' Loop through each field in the document
For Each fld In ActiveDocument.Fields
If fld.Type = wdFieldRef Then
' Check if the field is within the defined range
If fld.Result.InRange(rng) Then
' Select the field and exit the loop
fld.Select
Exit For
End If
End If
Next fld
End Sub
But it is not working and I cannot understand why.
SF
|