Thread: [Solved] Macro adjustment needed
View Single Post
 
Old 02-05-2020, 08:43 AM
Ulodesk Ulodesk is offline Windows 7 64bit Office 2013
Word 2013 Expert Cert
 
Join Date: Sep 2009
Location: Virginia
Posts: 866
Ulodesk is on a distinguished road
Default Macro adjustment needed

The following macro replaces single blank paragraphs in a selection with a tab starting the following paragraph, but it tabs any second successive blank line returns rather than removing them, and does not tab the first paragraph selected. Also, it brings up the "would you like to continue searching the document" dialogue, which is unnecessary. I tried toying with the macro, but I don't know what I'm doing, so it didn't work.

I appreciate your help.

Code:
Sub ParasBlankToTabSelection()
'
' Replaces blank paragraphs with a tab starting following paragraph in selected text.
'
'
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "^13^13"
        .Replacement.Text = "^p^t"
        .Forward = True
        .Wrap = wdFindAsk
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
End Sub
Reply With Quote