0
votes

I've built a custom cross reference tool in Word that allows the user to select multiple consecutive items to cross reference simultaneously. For example, holding down the Shift button and selecting Figure 1 to Figure 5 currently inserts "Figure 1 - 5" in my document, with both numbers being tied to their respective figures as updateable field codes. The field code toggle looks like this:

{ REF _Ref2236712 \h \* \Charformat } - { REF _Ref2236713 \h \# 0}

The field gets inserted into the document through VBA. Here's a sample of how the first field is inserted:

Selection.InsertCrossReference ReferenceType:=ReferenceType.Value, _
referencekind:=wdOnlyLabelAndNumber, referenceitem:=i, insertashyperlink:=HyperlinkChoice

...

Set fld1 = rng1.Fields(1)
fld1.Code.Text = fld1.Code.Text & "\* Charformat "
fld1.Update

How can I modify the field code VBA so that the final result in the document will appear as "Figures 1 - 5" instead of "Figure 1 - 5"? I tried adding strings like 's' and "s" in various places within the brackets but with no success.

Taking it one step further, is it possible to change "Appendix A - Appendix C" to display as "Appendices A - C"? This is a bigger challenge because it doesn't involve simply adding one letter to achieve plurality. Additionally, the numeric formatting switch from earlier (\# 0) doesn't apply to alphabetic characters (meaning Appendix C doesn't get trimmed down to just say C).

1
The ' Figure' text is the label for the item you are cross referencing. You can't modify this label without affecting every other item that uses the label. The way to solve you problem is to reduce the first cross reference to just the number and insert the figures text yourself as part of the macro. - freeflow
Thanks @Freeflow, it appears the solution was easier than I thought. I've edited to macro to insert "Figures" as plain text and made the fields show the numbers only. For any other readers, the field code text is set to fld1.Code.Text = fld1.Code.Text & " \# 0 \* Charformat " to make it show the number only. - NBSGS123

1 Answers

-1
votes

You need to modify your macro so it outputs: Figures { REF _Ref2236712 \h # 0} - { REF _Ref2236713 \h # 0}