吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 156|回复: 1
收起左侧

[经验求助] 求一个修改PPT文字指定颜色的宏

[复制链接]
leo_cn 发表于 2024-3-28 11:37
40吾爱币
文字有多种颜色 只修改黑色改成白色

最佳答案

查看完整内容

[mw_shl_code=asm,true]Sub ChangeBlackToWhite() Dim sld As Slide Dim shp As Shape Dim tf As TextFrame Dim rng As TextRange ' 遍历每一张幻灯片 For Each sld In ActivePresentation.Slides ' 遍历每一张幻灯片中的每一个形状 For Each shp In sld.Shapes ' 检查形状是否包含文本框 If shp.HasTextFrame Then Set tf = shp.T ...

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

Batcher 发表于 2024-3-28 11:37
[Asm] 纯文本查看 复制代码
Sub ChangeBlackToWhite()
    Dim sld As Slide
    Dim shp As Shape
    Dim tf As TextFrame
    Dim rng As TextRange

    ' 遍历每一张幻灯片
    For Each sld In ActivePresentation.Slides
        ' 遍历每一张幻灯片中的每一个形状
        For Each shp In sld.Shapes
            ' 检查形状是否包含文本框
            If shp.HasTextFrame Then
                Set tf = shp.TextFrame
                ' 检查文本框是否有文本
                If tf.HasText Then
                    Set rng = tf.TextRange
                    ' 遍历文本框中的每一部分(有可能是多段不同格式的文本)
                    For i = 1 To rng.Paragraphs.Count
                        With rng.Paragraphs(i).Font
                            ' 如果文字颜色是黑色,则改为白色
                            If .Color.RGB = RGB(0, 0, 0) Then
                                .Color.RGB = RGB(255, 255, 255)
                            End If
                        End With
                    Next i
                End If
            End If
        Next shp
    Next sld
End Sub

AI写的,我电脑上简单测试成功了,你试试。
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-4-29 15:01

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表