D
drmrbrewer
What I'm trying to do is to create a function that (when assigned to a
keyborad shortcut) allows me to insert a quick reference back to the
previous item in a numbered list.
So, say I've got:
1. Some stuff here
2. Some more stuff
3. Here I refer back to the stuff in 2.
So, when I'm typing in item 3, I just hit a keyboard shortcut to get
the "2" reference there.
What I've done so far is along the lines of:
Selection.InsertCrossReference ReferenceType:="Numbered item", _
ReferenceKind:=wdNumberFullContext,
ReferenceItem:=Selection.Range.ListFormat.ListValue - 1,
InsertAsHyperlink _
:=True, IncludePosition:=False
This actually works fine. UNLESS (and it's a big UNLESS) there is
another numbered list in my document before the one I'm working on.
Because that upsets the numbering.... it seems that "ListValue" just
returns the actual number of the current list item (3 in the example
above), and when that value (or 3 - 1 = 2 calculated from it) is set
as the ReferenceItem, it is a interpreted as a number applied across
the GLOBAL set of numbered items.
Example:
1. An annoying list here that messes my method up
[Some more stuff here]
1. Some stuff here
2. Some more stuff
3. Here I want to refer back to the previous item, but it comes out as
1.
When I try my cross-reference method in item 3, it works out "3 - 1 =
2", and then applies that to the global list of numbered items, and
no. 2 in that list is actually item 1 of the second list, not item 2
as I want.
Any idea as to how to make this work even when I have multiple
numbered groups in my document?
Thanks!!
Mike
keyborad shortcut) allows me to insert a quick reference back to the
previous item in a numbered list.
So, say I've got:
1. Some stuff here
2. Some more stuff
3. Here I refer back to the stuff in 2.
So, when I'm typing in item 3, I just hit a keyboard shortcut to get
the "2" reference there.
What I've done so far is along the lines of:
Selection.InsertCrossReference ReferenceType:="Numbered item", _
ReferenceKind:=wdNumberFullContext,
ReferenceItem:=Selection.Range.ListFormat.ListValue - 1,
InsertAsHyperlink _
:=True, IncludePosition:=False
This actually works fine. UNLESS (and it's a big UNLESS) there is
another numbered list in my document before the one I'm working on.
Because that upsets the numbering.... it seems that "ListValue" just
returns the actual number of the current list item (3 in the example
above), and when that value (or 3 - 1 = 2 calculated from it) is set
as the ReferenceItem, it is a interpreted as a number applied across
the GLOBAL set of numbered items.
Example:
1. An annoying list here that messes my method up
[Some more stuff here]
1. Some stuff here
2. Some more stuff
3. Here I want to refer back to the previous item, but it comes out as
1.
When I try my cross-reference method in item 3, it works out "3 - 1 =
2", and then applies that to the global list of numbered items, and
no. 2 in that list is actually item 1 of the second list, not item 2
as I want.
Any idea as to how to make this work even when I have multiple
numbered groups in my document?
Thanks!!
Mike