• 【Word VBA】批量替换字符


    很简单的Word VBA ,本例 替换 "填表日期:2019/12/31" 为 " "

    Sub test()
        Dim T
        Dim doc As Document
        Dim fd As FileDialog
        Dim vrtSelectedItem As Variant
        Set fd = Application.FileDialog(msoFileDialogFilePicker)
        With fd
            If .Show = -1 Then
                For Each vrtSelectedItem In .SelectedItems
                    Documents.Open FileName:=vrtSelectedItem
                    Set doc = ActiveDocument
                    
                    With doc.Content.Find
                        .Text = "填表日期:2019/12/31"
                        .Replacement.Text = " "
                        .Execute Replace:=wdReplaceAll, Forward:=True, Wrap:=wdFindContinue
                    End With
    
                    doc.Save
                    doc.Close
                    T = T + 1
                Next
            End If
        End With
        MsgBox "操作完成!!" & Chr(10) & "处理了 " & T & " 个文件。", vbOKOnly, "提示"
    End Sub
  • 相关阅读:
    单选多选样式写法
    深拷贝方法
    防抖和节流的实现
    yarn 常用指令
    前端性能监控
    全表 or 索引
    Order by
    DINSTINCT
    智力题
    概率问题
  • 原文地址:https://www.cnblogs.com/yzhyingcool/p/13833912.html
Copyright © 2020-2023  润新知