![]() |
#6
|
|||
|
|||
![]()
I think this accomplishes what you're trying to do.
I changed the Find-N-Replace code to a subroutine for easier reading and reuse. Code:
Sub Macro6() 'Select your desired text to be changed then run the macro. ‘ Options.Pagination = False 'turn off background page counts for speed Application.ScreenUpdating = False 'turn off screen changes for speed With Selection .Font.Bold = wdToggle 'toggle selection's Bold state Call Swap(“^p^p”,”<P>”) ‘placeholder between paragraphs Call Swap(“^p”,” “) ‘condense sentences Call swap(“<P>”,”^p^p”) ‘separate paragraphs again End with Selection.WholeStory.Font.Bold = wdToggle 'toggle entire document Bold state; why? Selection.EscapeKey ‘unsure if you need to exit selection? Application.ScreenUpdating = True 'turn screen changes back on Options.Pagination = True 'turn background page counts back on End Sub Sub Swap(First, Second) With Selection .Find.ClearFormatting .Find.Replacement.ClearFormatting With Selection.Find .Text = First .Replacement.Text = Second .Forward = True .Wrap = False .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With End With Selection.Find.Execute Replace:=wdReplaceAll End Sub Last edited by macropod; 09-24-2018 at 05:30 PM. Reason: Added code tags & formatting |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
Le_Blanc | Word VBA | 10 | 03-22-2021 11:38 AM |
Spell check macro within macro button field doesn't work in one document | samuelle | Word VBA | 0 | 07-20-2016 02:27 AM |
![]() |
LadyAna | Word | 1 | 12-06-2014 10:39 PM |
Macro Needed to bold specific lines and Macro to turn into CSV | anewteacher | Word VBA | 1 | 05-28-2014 03:59 PM |
custom icon, undo/redo for macro, permanent macro | Rapier | Excel | 0 | 08-05-2013 06:30 AM |