Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-12-2022, 12:29 PM
Ulodesk Ulodesk is offline Replacement refinement with straight to curly quotes requested Windows 10 Replacement refinement with straight to curly quotes requested Office 2016
Word 2013 Expert Cert
Replacement refinement with straight to curly quotes requested
 
Join Date: Sep 2009
Location: Virginia
Posts: 872
Ulodesk is on a distinguished road
Default Replacement refinement with straight to curly quotes requested

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
Reply With Quote
  #2  
Old 02-14-2022, 03:39 PM
Guessed's Avatar
Guessed Guessed is offline Replacement refinement with straight to curly quotes requested Windows 10 Replacement refinement with straight to curly quotes requested Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,163
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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
Reply With Quote
Reply



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
Replacement refinement with straight to curly quotes requested Changing Straight Quotes and Apostrophes into Curly Ones skeezix Word 4 02-10-2019 04:20 PM
Replacement refinement with straight to curly quotes requested 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

Other Forums: Access Forums

All times are GMT -7. The time now is 07:28 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft