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

相关推荐
ms365copilot4 小时前
Copilot生成水果店经营PPT
microsoft·产品运营·powerpoint·copilot
JAVA老架构AI智能化8 小时前
PPT Master Lite — 浏览器端 AI 驱动的 PPT 生成器
人工智能·powerpoint
copilot中国版9 小时前
PowerPoint Copilot内置技能|“优化幻灯片标题”有什么用?
powerpoint·copilot
qq_364682151 天前
汇报材料怎么快速生成PPT?科会通工具实操
powerpoint
言乐61 天前
HTML实现Word、Excel、PPT三种可切换背景,可键盘打字、和像素小人交互
html·word·powerpoint·excel·交互
copilot中国版3 天前
PPT Copilot 一键统一全篇版式,告别字体混乱、元素错位和重复排版
html·powerpoint·copilot
鲲穹AI种草7 天前
AI 生成 PPT 工具怎么选?鲲穹 PPT 功能实测与横向对比
人工智能·powerpoint
qq_3691736310 天前
一句话将 Word、PPT、PDF 发布成链接
人工智能·pdf·word·powerpoint·效率工具·ai 办公
weixin_4045512414 天前
使用 ZCode 改造 PPT 模板:实践复盘与能力边界
人工智能·powerpoint
小淮AI15 天前
AI生成PPT工具的功能观察:百度文库、Gamma、WPS AI
人工智能·powerpoint·wps