MS WORD 2003 GetCrossRefereceItems employs different list from InsertCrossReference

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???
 
B

Bob Buckland ?:-\)

Hi Mike,

You may want to use the link below to post this in the MS Word VBA newsgroup as well.

===============
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??? >>
--
Please let us know if this has helped,

Bob Buckland ?:)
MS Office System Products MVP

LINKS
A. Specific newsgroup/discussion group mentioned in this message:
news://msnews.microsoft.com/microsoft.public.word.vba.general
or via browser:
http://microsoft.com/communities/newsgroups/en-us/?dg=microsoft.public.vba.general

B. MS Office Community discussion/newsgroups via Web Browser
http://microsoft.com/office/community/en-us/default.mspx
or
Microsoft hosted newsgroups via Outlook Express/newsreader
news://msnews.microsoft.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top