Skip to content

Instantly share code, notes, and snippets.

@erikerhardt
Last active January 20, 2021 20:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erikerhardt/12663fb92eeef3211d02a9f88524cdb1 to your computer and use it in GitHub Desktop.
Save erikerhardt/12663fb92eeef3211d02a9f88524cdb1 to your computer and use it in GitHub Desktop.
MS Word Abbreviate existing Figure and Table cross-references
## Abbreviate existing Figure and Table cross-references
## https://www.msofficeforums.com/word/11965-making-cross-reference-say-fig-instead-figure.html
# Add with View > Macros > View Macros > Create > Select the current file (Project .. ThisDocument)
# > Paste this Macro > save document in docm format
Sub AbbreviateCaptions()
Dim Fld As Field
For Each Fld In ActiveDocument.Fields
With Fld
If Left(.Result.Text, 6) = "Figure" Then
.Locked = False
.Update
.Result.Text = Replace(.Result.Text, "Figure", "Fig", 1, 1)
.Locked = True
End If
If Left(.Result.Text, 5) = "Table" Then
.Locked = False
.Update
.Result.Text = Replace(.Result.Text, "Table", "Tab", 1, 1)
.Locked = True
End If
End With
Next
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment