zoukankan      html  css  js  c++  java
  • [VBA]批量替换PPT里的字体颜色

    不知道为什么计组老师的大量课件字体是伤害视力的亮蓝色……看久了眼睛疼,想把颜色替换成保护视力一点的灰色,但是找了N久也没找到在图形界面上直接操作的方法,于是在MSDN上晃了晃,Google了一下,写了个VBA小脚本,只替换选定颜色,这样可以保留红色或者其他颜色的高亮,顺便把让人分心的花花背景也干掉。

    Sub ReplaceColor()
    Dim shape As shape
    Dim slide As slide
    Dim txt As TextRange
    On Error Resume Next
    
    '替换背景颜色为白色
    ActivePresentation.SlideMaster.Background.Fill.Solid
    ActivePresentation.SlideMaster.Background.Fill.ForeColor.RGB = RGB(255, 255, 255)
    
    For Each slide In ActivePresentation.Slides
       For Each shape In slide.Shapes
          Set txt = shape.TextFrame.TextRange
          For Each sentence In txt.Sentences
            For Each word In sentence.Words
              '把蓝色的文字替换成灰色
              If word.Font.color.RGB = RGB(0, 0, 204) Or word.Font.color.RGB = RGB(0, 0, 122) Then
                With word.Font
                  .color.RGB = RGB(40, 40, 40)
                End With
              End If
            Next
          Next
       Next
    Next
    End Sub

    Before

    After

    我承认我只是在逃避复习计组………………用LP1、LP2、LP3这种标记名的汇编程序简直不想多看一眼好吗!!!

    其实还有一点缺陷,不能替换掉表格里的字体……不过真的不能再浪费时间跑去查文档鼓捣了(何况我几乎不会VB=。=) 明晚就考试,复习复习……

  • 相关阅读:
    响应式设计
    Flex box 弹性盒子布局
    下拉菜单  -
    html使用技巧
    nth-of-type(n)
    Js中 关于top、clientTop、scrollTop、offsetTop
    仿iPhone滑屏操作
    网页超过一页 点击回到顶部
    linux svn使用
    Linux查看CPU和内存使用情况
  • 原文地址:https://www.cnblogs.com/joyeecheung/p/3807285.html
Copyright © 2011-2022 走看看