![]() |
|
#1
|
|||
|
|||
|
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
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 |
|
#2
|
||||
|
||||
|
If your module has Option Explicit at the top of the module then the code has 4 critical lines, not 3. Perhaps you neglected to include the variable declaration at the top of the code
Dim bSmtQt As Boolean
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Curly Smart Quotes Switch to Straight Smart Quotes in New Chapters | TheWriterBloke | Word | 3 | 03-29-2019 03:11 AM |
Changing Straight Quotes and Apostrophes into Curly Ones
|
skeezix | Word | 4 | 02-10-2019 04:20 PM |
How to replace straight quotes with smart quotes in existing document
|
PABwriter | Word | 4 | 05-27-2016 03:36 PM |
| Straight Vs Curly Quotation Marks | FOsmund | Word | 4 | 04-16-2015 01:48 PM |
| Balky Curly Quotes | JamesT | Word | 0 | 01-23-2010 05:36 PM |