Skip to content

Instantly share code, notes, and snippets.

@brentmaxwell
Last active November 25, 2019 15:45
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 brentmaxwell/41e90dcf7d3a66127c466628a974f77d to your computer and use it in GitHub Desktop.
Save brentmaxwell/41e90dcf7d3a66127c466628a974f77d to your computer and use it in GitHub Desktop.
Swap smart and straight quotes in Microsoft Word
Sub ChangeDoubleStraightQuotesToSmartQuotes()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = """"
.Replacement.Text = """"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
Sub ChangeSingleStraightQuotesToSmartQuotes()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "'"
.Replacement.Text = "'"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
Sub RemoveSmartQuotes()
Dim vFindText As Variant
Dim vReplText As Variant
Dim i As Long
vFindText = Array("[^0145^0146]", "[^0147^0148]")
vReplText = Array("^039", "^034")
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Forward = True
.Wrap = wdFindContinue
.MatchWholeWord = True
.MatchWildcards = True
For i = LBound(vFindText) To UBound(vFindText)
.Text = vFindText(i)
.Replacement.Text = vReplText(i)
.Execute Replace:=wdReplaceAll
Next i
End With
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment