查找PPT中某种字体的全部对应文字

本文章的目的是找到某种字体的文字,而不是替换某种字体的文字,也不是将某种字体全部替换为另外一种文字。

第一步在PPT中按下ALT+F11

出现以下窗口

第二步:点击插入->模块

第三步将以下代码输入到窗体中

vba 复制代码
Sub FindTextByFont()
    Dim slide As slide
    Dim shape As shape
    Dim textRange As textRange
    Dim fontName As String
    Dim foundTexts As String
    Dim found As Boolean

    ' 要查找的字体名称
    fontName = InputBox("请输入要查找的字体名称:", "查找字体")

    If fontName = "" Then Exit Sub

    found = False
    foundTexts = "以下是使用字体 """ & fontName & """ 的文字:" & vbCrLf & vbCrLf

    ' 遍历所有幻灯片
    For Each slide In ActivePresentation.Slides
        ' 遍历每张幻灯片上的所有形状
        For Each shape In slide.Shapes
            ' 检查形状是否有文本
            If shape.HasTextFrame Then
                If shape.TextFrame.HasText Then
                    ' 遍历形状的所有文本范围
                    For Each textRange In shape.TextFrame.textRange.Runs
                        ' 如果文本范围的字体名称匹配
                        If textRange.Font.Name = fontName Then
                            found = True
                            foundTexts = foundTexts & "幻灯片 " & slide.SlideIndex & " 中的文字: " & textRange.Text & vbCrLf
                        End If
                    Next textRange
                End If
            End If
        Next shape
    Next slide

    If found Then
        MsgBox foundTexts
    Else
        MsgBox "没有找到使用字体 """ & fontName & """ 的文字。"
    End If
End Sub

第四步:按下F5 ,运行后会弹出新的窗口
输入字体后,会列出所有的文字位置

相关推荐
ai_top_trends16 小时前
不同 AI 生成 2026 年工作计划 PPT 的使用门槛对比
人工智能·python·powerpoint
shandianchengzi17 小时前
【记录】从安装到增强:Google Antigravity 深度调优手册 & PPT-master 推荐
powerpoint
小真zzz18 小时前
ChatPPT与WPS AI深度产品对比:AI美化技术的全面较量
人工智能·powerpoint·wps·ppt·aippt·banana
aitoolhub20 小时前
PPT在线制作:如何用模板提升内容输出效率
人工智能·aigc·powerpoint·ppt·视觉传达
轻竹办公PPT21 小时前
AI 自动生成 PPT 实用吗?深度体验后的客观评价
人工智能·python·powerpoint
开开心心_Every1 天前
重复图片智能清理工具:快速查重批量删除
java·服务器·开发语言·前端·学习·edge·powerpoint
开开心心_Every1 天前
一键隐藏窗口到系统托盘:支持任意软件摸鱼
服务器·前端·python·学习·edge·django·powerpoint
JaredYe1 天前
用 Node.js 从旧版 PPT 中提取文本:轻量开源工具 ppt-to-text
node.js·powerpoint·ppt
dagouaofei1 天前
AI PPT 工具怎么选?5个维度对比6款产品
人工智能·python·powerpoint
Access开发易登软件1 天前
Access自动生成PPT报告完全指南
数据库·powerpoint·vba·vb·access·access开发