Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 02-06-2022, 02:23 AM
gmayor's Avatar
gmayor gmayor is offline From recorded tro rational Windows 10 From recorded tro rational Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,142
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

If it ain't broke - don't fix it! However I would probably do it as follows. Depending on the document, you may have to address all the story ranges. This just accesses the document body.

Code:
Sub ReplaceQuotes()
' Macro to replace in the entire document:
' straight single and double straight quotes with curly
Dim sFormat As Boolean
    sFormat = Options.AutoFormatAsYouTypeReplaceQuotes
    Options.AutoFormatReplaceQuotes = True
    ActiveDocument.Range.AutoFormat
     Options.AutoFormatAsYouTypeReplaceQuotes = sFormat
   ' Call the FixSpace sub
     FixSpace ActiveDocument.Range 
lbl_Exit:
    Exit Sub
End Sub

Private Sub FixSpace(oRng As Range)
' remove tabs;
' replace manual line returns with hard returns; and
' remove empty paragraphs
Dim oFind As Range
    Set oFind = oRng.Duplicate
    With oFind.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Text = "^t"
        .Replacement.Text = ""
        .Execute Replace:=wdReplaceAll
    End With
    Set oFind = oRng.Duplicate
    With oFind.Find
        .Text = "^l"
        .Replacement.Text = "^p"
        .Execute Replace:=wdReplaceAll
    End With
    With oFind.Find
        .Text = "^13{1,}"
        .Replacement.Text = "^p"
        .Execute MatchWildcards:=True, Replace:=wdReplaceAll
    End With
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
From recorded tro rational Please help! Macros not recorded as expected Chibiberu Word VBA 4 03-30-2019 02:42 AM
Modify recorded macro to run until end of document peter961 Word VBA 1 09-04-2017 02:50 PM
Embedded Video Not Playing in Recorded Presentation bhadden1 PowerPoint 0 08-16-2017 03:07 PM
Add previously recorded sound and synchronize with slide annimations daniellouw PowerPoint 1 03-03-2017 11:14 AM
Can I record more to add on to a recorded Macro? Clueless in Seattle Word VBA 3 05-25-2015 01:21 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:22 AM.


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