word 批量 替换 VBA word 如何利用vba实现批量替换字符?

\u5982\u4f55\u7528VBA\u5b9e\u73b0WORD\u6279\u91cf\u66ff\u6362\uff1f


For i = 1 To n 'n\u662flistview1\u7684\u884c\u6570 Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = ListView1.ListItems(i).SubItems(0) 'Findstr=listview1\u7684\u7b2ci\u884c\u7b2c1\u5217\u5bf9\u5e94\u5355\u5143\u683c\u7684\u5185\u5bb9 .Replacement.Text = ListView1.ListItems(i).SubItems(1) 'Findstr=listview1\u7684\u7b2ci\u884c\u7b2c2\u5217\u5bf9\u5e94\u5355\u5143\u683c\u7684\u5185\u5bb9 .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchByte = True .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll ListView1.selectedItem = i Next MsgBox "\u5904\u7406\u5b8c\u6bd5\uff01", vbInformation + vbOKOnly, "\u6d88\u606f" ListView1.selectedItem = 1

\u5f55\u5236\u5b8f\uff0c\u66ff\u6362\u6240\u6709\u76841\u90fd\u66ff\u6362\u4e3akey\u201c1\u201d\uff0c\u7136\u540e\u5728\u4ee3\u7801\u91cc\u9762\u590d\u5236\uff08\u6240\u6709\u76841\u90fd\u66ff\u6362\u4e3akey\u201c1\u201d)\u4fee\u6539\u4e3a\u5176\u4ed6\u66ff\u6362\u3002

Sub 宏1()
    mypath = ThisDocument.Path & "\" '
    mydoc = Dir(mypath & "*.doc")
    myname = ThisDocument.Name
    Do While Len(mydoc)
        If mydoc <> myname Then
            Set curDoc = Documents.Open(mypath & myname)
            Selection.EndKey Unit:=wdStory
            Selection.Find.ClearFormatting
            Selection.Find.Replacement.ClearFormatting
            With Selection.Find
                .Text = "52[0-9]{4}.[0-9]{3}"
                .Replacement.Text = "38^&"
                .Forward = True
                .Wrap = wdFindContinue
                .Format = False
                .MatchCase = False
                .MatchWholeWord = False
                .MatchByte = False
                .MatchAllWordForms = False
                .MatchSoundsLike = False
                .MatchWildcards = True
            End With
            Selection.Find.Execute Replace:=wdReplaceAll
            curDoc.Close True
        End If
        mydoc = Dir
    Loop
    MsgBox "Duang 的一下,完成了!"
End Sub


 



扩展阅读:word 批量 页面 删除 ... vba批量替换word内容 ... excel快速批量替换 ... vba word 替换 字体颜色 ... excel vba批量替换 ... vba如何快速导出批量word ... word vba 查找和替换 ... word一键调整全部图片大小 ... 批量 替换 免安装 ...

本站交流只代表网友个人观点,与本站立场无关
欢迎反馈与建议,请联系电邮
2024© 车视网