Last active
January 20, 2021 20:46
-
-
Save erikerhardt/12663fb92eeef3211d02a9f88524cdb1 to your computer and use it in GitHub Desktop.
MS Word Abbreviate existing Figure and Table cross-references
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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