VBA WORD: Remove double paragraph marks

后端 未结 3 1916
暖寄归人
暖寄归人 2020-12-20 06:38

Trying to move excessive paragraph gaps via this procedure.

Sub RemoveGaps()
    wrdDoc.Content.Select

    Selection.Find.ClearFormatting
    Selection.Find         


        
3条回答
  •  攒了一身酷
    2020-12-20 06:57

    Try this

    Sub RemoveGaps()
        wrdDoc.Content.Select
    
        Selection.Find.ClearFormatting
        Selection.Find.Replacement.ClearFormatting
    
        With Selection.Find
            .Text = "^p^p" '<~~~ See this
            .Replacement.Text = "^p"
    
            .Forward = True
            .Wrap = wdFindContinue
            .Format = False
            .MatchCase = False
            .MatchWholeWord = True
            .MatchWildcards = False '<~~ Set this to false
        End With
    
        Selection.Find.Execute Replace:=wdReplaceAll
    
        If Selection.Find.Execute = True Then
            Call RemoveGaps
        End If
    End Sub
    

提交回复
热议问题