J
Jezebel
I have some VB code that automatically inserts cross-references:
1. Retrieve the list of headings --
pMyheadings = WordDoc.GetCrossReferenceItems(wdRefTypeHeading)
2. Select one heading from the array (= pIndex)
3. Insert the selected cross-reference --
WordDoc.InsertCrossReference ReferenceType:=wdRefTypeHeading, _
ReferenceKind:=wdContentText, _
ReferenceItem:=pIndex, _
InsertAsHyperlink:=pHyperlink, _
IncludePosition:=False
Most of the time this works as expected; but I have a couple of documents in
which it behaves strangely -- there are some Index values on which the
Insert statement fails (with the brilliantly helpful message "Command
failed") -- and subsequent index values return the wrong heading. Eg, Index
= 12 fails; but using Index = 13 inserts a cross-reference to the 12th item
in the GetCrossReferenceItems() array.
Using the manual Insert > Cross-Reference function works fine.
The only features of the documents on which this fails that are at all
unusual are a) rather longer than normal, and b) some non-built-in styles
with outline levels 1 and 3.
Any thoughts or prior convictions?
1. Retrieve the list of headings --
pMyheadings = WordDoc.GetCrossReferenceItems(wdRefTypeHeading)
2. Select one heading from the array (= pIndex)
3. Insert the selected cross-reference --
WordDoc.InsertCrossReference ReferenceType:=wdRefTypeHeading, _
ReferenceKind:=wdContentText, _
ReferenceItem:=pIndex, _
InsertAsHyperlink:=pHyperlink, _
IncludePosition:=False
Most of the time this works as expected; but I have a couple of documents in
which it behaves strangely -- there are some Index values on which the
Insert statement fails (with the brilliantly helpful message "Command
failed") -- and subsequent index values return the wrong heading. Eg, Index
= 12 fails; but using Index = 13 inserts a cross-reference to the 12th item
in the GetCrossReferenceItems() array.
Using the manual Insert > Cross-Reference function works fine.
The only features of the documents on which this fails that are at all
unusual are a) rather longer than normal, and b) some non-built-in styles
with outline levels 1 and 3.
Any thoughts or prior convictions?