Hi. I have a longer macro that cleans up various things in a document, applying each to the entire document. It includes the Find/Replace of both single and double quotation marks to change them from straight to curly. This, of course, depends on having the relevant checkbox checked in AutoFormatAsYouType. I do, but I am wondering how I can alter the macro to check that box if it isn't checked in a remote user's local Word. (Some of my colleagues are computer-challenged; I'm trying to get some efficiency with the macro.)
What I have now is this (it comes in between other things the macro does:
Code:
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
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
I found Paul's post, below, that seems to deal with my issue in the third line; I don't know VBA, so I don't know if it actually checks the box or what the first two lines do, though clearly related. I tried several variations on inserting these three lines, or just the third, into my macro, but each brought up a pop-up about a break in the code. If you please, what do I need to do to make it work? Thank you.
Code:
Sub Demo()
Dim bSmtQt As Boolean
bSmtQt = Options.AutoFormatAsYouTypeReplaceQuotes
Options.AutoFormatAsYouTypeReplaceQuotes = True
With ActiveDocument.Range.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = """"
.Replacement.Text = """"
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
End With
Options.AutoFormatAsYouTypeReplaceQuotes = bSmtQt
End Sub