M
mike.lay
I have written a VB macro in MS word 2003 to examine the "numbered"
crossreferences of a document and add selected items of this list to
the document via the InsertCrossReferece method. The list of
crossrefereced items was retrieved by the GetCrossReferenceItems
method. It appears that the list I retrieve via GetCrossReferenceItems
is not the same as the list employed by InsertCrossReference. The
latter seems to include bulleted list items intermixed with the
numbered items.
Here is the code that shows the problem. This creates a table and
inserts all the "numbered" items via InsertCrossReference in the first
two table colums and the corresponding item from the
GetCrossReferenceItems list that correspond to the same index value.
They should point to the same item but do not.
ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=2,
NumColumns:= _
3, DefaultTableBehavior:=wdWord9TableBehavior,
AutoFitBehavior:= _
wdAutoFitContent
myNumberedItems =
ActiveDocument.GetCrossReferenceItems(wdRefTypeNumberedItem)
For i = 1 To UBound(myNumberedItems)
myRef = myNumberedItems(i)
Selection.InsertRowsBelow 1
Selection.Collapse Direction:=wdCollapseStart
Selection.InsertCrossReference
ReferenceType:=wdRefTypeNumberedItem, _
ReferenceKind:=wdNumberNoContext, ReferenceItem:=i,
InsertAsHyperlink:=True
Selection.MoveRight Unit:=wdCell
Selection.InsertCrossReference
ReferenceType:=wdRefTypeNumberedItem, _
ReferenceKind:=wdContentText, ReferenceItem:=i,
InsertAsHyperlink:=True
Selection.MoveRight Unit:=wdCell
Selection.InsertAfter myRef
Next i
Has anyone else encountered this and know of a solution???
crossreferences of a document and add selected items of this list to
the document via the InsertCrossReferece method. The list of
crossrefereced items was retrieved by the GetCrossReferenceItems
method. It appears that the list I retrieve via GetCrossReferenceItems
is not the same as the list employed by InsertCrossReference. The
latter seems to include bulleted list items intermixed with the
numbered items.
Here is the code that shows the problem. This creates a table and
inserts all the "numbered" items via InsertCrossReference in the first
two table colums and the corresponding item from the
GetCrossReferenceItems list that correspond to the same index value.
They should point to the same item but do not.
ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=2,
NumColumns:= _
3, DefaultTableBehavior:=wdWord9TableBehavior,
AutoFitBehavior:= _
wdAutoFitContent
myNumberedItems =
ActiveDocument.GetCrossReferenceItems(wdRefTypeNumberedItem)
For i = 1 To UBound(myNumberedItems)
myRef = myNumberedItems(i)
Selection.InsertRowsBelow 1
Selection.Collapse Direction:=wdCollapseStart
Selection.InsertCrossReference
ReferenceType:=wdRefTypeNumberedItem, _
ReferenceKind:=wdNumberNoContext, ReferenceItem:=i,
InsertAsHyperlink:=True
Selection.MoveRight Unit:=wdCell
Selection.InsertCrossReference
ReferenceType:=wdRefTypeNumberedItem, _
ReferenceKind:=wdContentText, ReferenceItem:=i,
InsertAsHyperlink:=True
Selection.MoveRight Unit:=wdCell
Selection.InsertAfter myRef
Next i
Has anyone else encountered this and know of a solution???