Skip to content

Instantly share code, notes, and snippets.

@japborst
Created January 16, 2017 10:39
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save japborst/439e75e8708455ba17e0c8fd204a8c90 to your computer and use it in GitHub Desktop.
Save japborst/439e75e8708455ba17e0c8fd204a8c90 to your computer and use it in GitHub Desktop.
Simple cross-reference macros for auto selecting appropriate boxes
' Because inserting cross-references is terrible in Word, these macros
' makes life a little easier by selecting the appropriate drop-down boxes
' Open issue: NumLock may be disabled
Sub InsertFigureReference()
' Reference a Figure and insert Only label and number
With Application.Dialogs(wdDialogInsertCrossReference)
SendKeys "ff{TAB}{DOWN 2}{ENTER}", True
.InsertAsHyperLink = 1
.InsertPosition = 0
.Show
End With
End Sub
Sub InsertEqReference()
' Reference an Equation and insert Entire caption
With Application.Dialogs(wdDialogInsertCrossReference)
SendKeys "eq{TAB}{DOWN 0}{ENTER}", True
.InsertAsHyperLink = 1
.InsertPosition = 0
.Show
End With
End Sub
Sub InsertTableReference()
' Reference a Table and insert Only label and number
With Application.Dialogs(wdDialogInsertCrossReference)
SendKeys "t{TAB}{DOWN 2}{ENTER}", True
.InsertAsHyperLink = 1
.InsertPosition = 0
.Show
End With
End Sub
Sub InsertHeadingReference()
' Reference a Heading and insert heading number
With Application.Dialogs(wdDialogInsertCrossReference)
SendKeys "hh{TAB}{DOWN 3}{ENTER}", True
.InsertAsHyperLink = 1
.InsertPosition = 0
.Show
End With
End Sub
Sub InsertAppendix()
' Reference a Numbered Item and insert Paragraph number
With Application.Dialogs(wdDialogInsertCrossReference)
SendKeys "n{TAB}{DOWN 2}{ENTER}{TAB 3}", True
.InsertAsHyperLink = 1
.InsertPosition = 0
.Show
End With
End Sub
@Larvorniel
Copy link

This is a brilliantly straightforward solution to this considerable inadequacy in Word. Well done, mate. Many thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment