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

相关推荐
X1A0RAN8 天前
PPT 图片批量处理教程:导出全部幻灯片 · 提取全部素材
开发语言·javascript·powerpoint
死磕音视频17 天前
PowerPoint Copilot 入门:用 Interactive Slide 做出可点击讲解页
powerpoint·copilot·演示文稿·交互幻灯片
FinelyYang17 天前
uniapp使用kkfileview在线预览ppt,excel,word,pdf类型文件
pdf·uni-app·powerpoint
zhippt_101417 天前
截图、课件图、设计稿怎么变成可编辑PPT?图转PPT实测
powerpoint
ms365copilot18 天前
Copilot 笔记本,研究内容整理完变成 PowerPoint
powerpoint·copilot
jcqcool19 天前
win11下ppt内置的Flash 动画还直接能动起来:我做了一个 兼容播放小工具
powerpoint
zhippt_101419 天前
只剩截图没有源文件?图转PPT把图片还原成可编辑幻灯片
前端·人工智能·powerpoint
zhippt_101420 天前
教师做课件太耗时?AI生成PPT工具与图转PPT实测梳理
人工智能·html·powerpoint
zhippt_101422 天前
汇报总结PPT怎么做更快?5款AI生成PPT工具实测横评
人工智能·powerpoint
copilot中国版22 天前
PPT 新技能「创建项目启动会」:项目还没开会,Copilot 先把启动会 PPT 搭好了
powerpoint·copilot