Learn

The forum of documents and methods for studying - Lượm lặt kiến thức


    [Word] Macro to clean tab, space and multiline

    QaniTri
    QaniTri
    Admin

    Nam Libra Monkey
    Tổng số bài gửi : 1568
    Tiền xu Ⓑ : 3891
    Được cảm ơn № : 6
    Ngày khởi sự Ngày khởi sự : 07/01/2013
    Đến từ Đến từ : HCMC
    Côngviệc / Sởthix Côngviệc / Sởthix : Languages, Softwares, Sciences, Martial arts

    [Word] Macro to clean tab, space and multiline Empty [Word] Macro to clean tab, space and multiline

    Bài gửi by QaniTri 15th June 2017, 18:38

    Code:
    Sub CleanSpace()
    '
    ' CleanSpace Macro
    ' Clean space and multiline
    '
        Selection.TypeText Text:=vbTab
        Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
        Selection.Copy
        Selection.Find.ClearFormatting
        Selection.Find.Replacement.ClearFormatting
        With Selection.Find
            .Text = vbTab
            .Replacement.Text = ""
            .Forward = True
            .Wrap = wdFindAsk
            .Format = False
            .MatchCase = False
            .MatchWholeWord = False
            .MatchByte = False
            .CorrectHangulEndings = False
            .HanjaPhoneticHangul = False
            .MatchAllWordForms = False
            .MatchSoundsLike = False
            .MatchWildcards = False
            .MatchFuzzy = False
        End With
        Selection.Find.Execute Replace:=wdReplaceAll
        With Selection.Find
            .Text = " "
            .Replacement.Text = ""
            .Forward = True
            .Wrap = wdFindAsk
            .Format = False
            .MatchCase = False
            .MatchWholeWord = False
            .MatchByte = False
            .CorrectHangulEndings = False
            .HanjaPhoneticHangul = False
            .MatchAllWordForms = False
            .MatchSoundsLike = False
            .MatchWildcards = False
            .MatchFuzzy = False
        End With
        Selection.Find.Execute Replace:=wdReplaceAll
        With Selection.Find
            .Text = "^p^p"
            .Replacement.Text = "^p"
            .Forward = True
            .Wrap = wdFindAsk
            .Format = False
            .MatchCase = False
            .MatchWholeWord = False
            .MatchByte = False
            .CorrectHangulEndings = False
            .HanjaPhoneticHangul = False
            .MatchAllWordForms = False
            .MatchSoundsLike = False
            .MatchWildcards = False
            .MatchFuzzy = False
        End With
        Selection.Find.Execute Replace:=wdReplaceAll
        Selection.TypeParagraph
    End Sub


      Hôm nay: 29th March 2024, 02:22