Sub ReplaceFontColorAndName() '设置要替换的字体颜色和字体名称 Dim oldColor As Long oldColor = RGB(255, 0, 0) Dim newColor As Long newColor = RGB(0, 0, 255) Dim oldFontName As String oldFontName = 'Arial' Dim newFontName As String newFontName = 'Times New Roman'

'遍历每个slide
Dim sld As Slide
For Each sld In ActivePresentation.Slides
    '遍历每个shape
    Dim shp As Shape
    For Each shp In sld.Shapes
        '替换字体颜色
        If shp.HasTextFrame Then
            Dim tr As TextRange
            Set tr = shp.TextFrame.TextRange
            tr.Font.Color.RGB = Replace(tr.Font.Color.RGB, oldColor, newColor)
        End If
        '替换字体名称
        If shp.HasTextFrame Then
            Dim tr2 As TextRange
            Set tr2 = shp.TextFrame.TextRange
            tr2.Font.Name = Replace(tr2.Font.Name, oldFontName, newFontName)
        End If
    Next shp
Next sld

'提示替换完成
MsgBox '替换完成!'

End Sub


原文地址: https://www.cveoy.top/t/topic/nMBH 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录