Thread: Stumped
View Single Post
 
Old 12-13-2021, 10:52 AM
Ulodesk Ulodesk is offline Windows 10 Office 2016
Word 2013 Expert Cert
 
Join Date: Sep 2009
Location: Virginia
Posts: 872
Ulodesk is on a distinguished road
Default Stumped

Back again. Not a coder, obviously.

Reviewing some of my macros this morning, I discovered some were not doing what they are supposed to. I have managed to fix a couple but am stumped here.

The first of the following two works fine. The second refuses to stop at the end of whatever selection I make and continues to the end of the document. My test document is attached. For the life of me, non-coder that I am, I cannot see the difference in teh code that would make this happen. Help appreciated.

Code:
Sub ParasDeleteMultiSelection()
'
' Macro6 Macro
'
'
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "^13{2,}"
        .Replacement.Text = "^p"
        .Forward = True
        .Wrap = wdFindAsk
        .Format = False
        .MatchWildcards = True
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
End Sub
Code:
Sub ParasInsertBlanksSelection()
'
' ParasInsertBlanksSelection Macro
'
'
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "[^13]"
        .Replacement.Text = "^p^p"
        .Forward = True
        .Wrap = wdFindAsk
        .Format = False
        .MatchWildcards = True
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
End Sub
Attached Files
File Type: docx Test doc.docx (16.0 KB, 9 views)
Reply With Quote