如何利用word vba修改文档中数字的字体

如何利用word vba修改文档中全部数字的字体,求详细代码,只修改数字字体。

数字的字体不能单独修改,但是如果是所有英文/数字的字体,是可以修改的。

.font.NameAscii="Times New Roman"

WordVB:通配符替换——更改字体属性

一 代码

Sub 修改Word文档数字字体()
    Dim aDoc As Document
    Set aDoc = ActiveDocument
    
    Application.ScreenUpdating = False
    
    With aDoc.Content.Find
        .ClearFormatting
        .Wrap = wdFindStop
        .MatchWildcards = True              '使用通配符
        .Text = "[0-9]{1,}"                 '查找框内容:数字
        
        With .Replacement
            .ClearFormatting
            .Text = "^&"                    '替换框内容
            With .Font
                .Name = "Times New Roman"   '西方字体
                .NameFarEast = "宋体"       '中文字体
                .Size = 20                  '字号
                .ColorIndex = wdRed         '字体颜色
                .Bold = True                '加粗
                .Italic = True              '倾斜
                .Underline = wdUnderlineSingle      '下划线类型
                .UnderlineColor = wdColorAutomatic  '下划线颜色
            End With
        End With
        
        .Execute Replace:=wdReplaceAll      '执行替换
    End With
    
    Application.ScreenUpdating = True
    Set aDoc = Nothing
End Sub

二 执行效果

img

有Office办公组件/VBA办公自动化问题可以和我交流哈