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

相关推荐
薛纪克15 分钟前
企业级 AI PPT 设计的最后一公里
人工智能·powerpoint
淮北4941 天前
如何制作ppt(进行中)
ai·powerpoint·逻辑·版式
Metaphor6921 天前
使用 Python 将 PowerPoint 转换为 PDF
python·pdf·powerpoint
AI工具指南1 天前
2026年AI PPT工具横评:内容准确性、生成速度与排版质量实测
人工智能·powerpoint
dingxingdi6 天前
AI PPT 制作流程
人工智能·powerpoint
小真zzz8 天前
2026年免费AI PPT工具深度评测:多款实用工具推荐
人工智能·搜索引擎·ai·powerpoint·ppt
神码观察12 天前
WorkBuddy高效制作PPT与交互式课件实操指南
powerpoint
SpaceAIGlobal12 天前
医护人员使用AI生成PPT:如何保证原始数据不被篡改?
人工智能·powerpoint
cyhysr13 天前
Python读取ppt文本转存txt
python·powerpoint
A懿轩A13 天前
【NotebookLM 使用教程】 Slides 指令库:11套通用PPT风格Prompt(含中英文对照)
python·prompt·powerpoint·ppt·notebooklm