查找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 ,运行后会弹出新的窗口
输入字体后,会列出所有的文字位置

相关推荐
JoshRen2 小时前
2026教程:用Gemini 3镜像站将技术白皮书自动转化为演讲PPT大纲与备注(附国内免费方案)
powerpoint
qingmiaozhuan2 天前
PPT突然卡住了没保存怎么办?了解更多恢复知识
powerpoint
开开心心就好2 天前
无品牌限制的手机电视投屏工具推荐
科技·游戏·智能手机·edge·电脑·逻辑回归·powerpoint
E_ICEBLUE2 天前
使用 Python 在 PowerPoint 中添加或移除背景(图像与颜色)
python·powerpoint
悟乙己3 天前
解析 Agent 时代的 HTML PPT SKILLS: html-ppt-skill
前端·html·powerpoint
chatexcel4 天前
专业报告PPT自动生成教程:基于元空AI的文档解析与智能排版实践
人工智能·powerpoint
深念Y5 天前
AI时代办公格式的演进:PPT与Word的替代已现,Excel将走向何方?
数据库·人工智能·html·word·powerpoint·excel·markdown
无巧不成书02186 天前
2026年AI PPT全流程最优落地方案
人工智能·powerpoint
开开心心就好7 天前
避免借电脑尴尬的故障模拟工具
科技·游戏·visualstudio·edge·pdf·电脑·powerpoint
2501_930707788 天前
使用C#代码在 PowerPoint 中创建组合图表
开发语言·c#·powerpoint