W
Where am I?
Hello,
Word 2002.
I am attempting to loop through the cross references collection, find a
match based on some text that I have already captured and insert a cross
reference to the item. The code is given below. The instr command does not
resolve correctly but using the debug window there should be a value found.
Please help.
Sub Generic_References(toref$)
Dim i%, x%
myHeadings = ActiveDocument.GetCrossReferenceItems(wdRefTypeHeading)
x% = 1
For i% = 1 To UBound(myHeadings)
If InStr(myHeadings(i%), toref$) <> 0 Then
Selection.InsertCrossReference ReferenceType:=wdRefTypeHeading, _
ReferenceKind:=wdNumberRelativeContext, ReferenceItem:=i%
Selection.TypeText " "
Exit For 'once it is found it exits
End If
Next i
End Sub
Word 2002.
I am attempting to loop through the cross references collection, find a
match based on some text that I have already captured and insert a cross
reference to the item. The code is given below. The instr command does not
resolve correctly but using the debug window there should be a value found.
Please help.
Sub Generic_References(toref$)
Dim i%, x%
myHeadings = ActiveDocument.GetCrossReferenceItems(wdRefTypeHeading)
x% = 1
For i% = 1 To UBound(myHeadings)
If InStr(myHeadings(i%), toref$) <> 0 Then
Selection.InsertCrossReference ReferenceType:=wdRefTypeHeading, _
ReferenceKind:=wdNumberRelativeContext, ReferenceItem:=i%
Selection.TypeText " "
Exit For 'once it is found it exits
End If
Next i
End Sub