7

I mostly write technical documentation. The documents need a lot of cross references. The format of my cross references are always the same:

<heading-number> <space> <heading-text>.

Adding these using the cross reference dialog is a pain. Find the heading, select paragraph-number from the drop down, insert, select paragraph-text from the drop down, insert, go back to the doc, insert the space (and, normally, change the inserted heading-text to Italic).

Is there any more convenient way of doing this? I did look at existing questions about cross-references (and there's a bunch of those) but none seemed to cover this issue.

2 Answers 2

3

I have written a macro to comfortably insert cross references, avoiding all the hassle of the cross reference dialog that you have described.
It can insert either <heading-number> or <heading-text>, but would be easily adaptable to insert the desired combination of both.

3
  • Thanks. I will make use of this - but unfortunately, not at work where they have disabled use of macros... Jun 30, 2019 at 9:22
  • I've just checked-in a new version of the macro. It is now configurable to support things like your <heading-number> <space> <heading-text>.
    – Traveler
    Jul 9, 2019 at 22:21
  • Thank you ! I have opened an issue to enquire about MacOS, which is not currently supported May 8, 2023 at 14:42
0

7 years ago and still people fighting with that. Here is my small contribution: Dim strCode As String

With Dialogs(wdDialogInsertCrossReference)
    .ReferenceType = "Numbered item"
    .ReferenceKind = wdNumberRelativeContext
    .InsertAsHyperlink = True
    .SeparateNumbers = False
    .Show
End With
Selection.TypeBackspace 'trick it selects the complete field
Selection.Copy
Selection.MoveRight Unit:=wdCharacter, Count:=1 ' unselect
Selection.TypeText Text:=" " ' Separate with one space
Selection.PasteAndFormat (wdPasteDefault) ' duplicate the copied field
Selection.TypeBackspace ' Select the duplicated field
strCode = Selection.Fields(1).Code ' get the code from the field
strCode = Replace(strCode, "\r ", "") ' Remove option to have paragraph text
strCode = Replace(strCode, "\w ", "")
Selection.Fields(1).Code.Text = strCode ' Update the text of the ;code text
Selection.Fields.Update ' Update the field to display § text
Selection.MoveRight Unit:=wdCharacter, Count:=1 ' Deselect the updated field
Selection.TypeText Text:=" " ' add a space at the end

End Sub

Provided as is, it works for me ;-) Have fun and spare time to fun...

1
  • 1
    Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Feb 9 at 17:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .