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

相关推荐
张鹏993 天前
【Microsoft® PowerPoint for Mac】MAC一键导出PPT备注
microsoft·macos·powerpoint
张鹏993 天前
【Microsoft PowerPoint for Mac】2分钟配置-MAC一键删除PPT中的所有备注
microsoft·macos·powerpoint
mseaspring3 天前
DeepSeek+Kimi 一键生成100种PPT
powerpoint
二哥不像程序员3 天前
解放大脑!用DeepSeek自动生成PPT!
人工智能·powerpoint·deepseek
烟锁池塘柳04 天前
WPS PPT插入各种线型形状(如画直线)的时候总是有箭头,如何还原成只画直线
powerpoint·wps
Ljw...4 天前
DeepSeek+Kimi生成高质量PPT
数据库·c++·powerpoint·ppt·deepseek
剑盾云安全专家7 天前
如何利用AI制作PPT,轻松实现高效演示
人工智能·科技·学习·powerpoint·软件
剑盾云安全专家8 天前
如何通过AI让PPT制作更轻松:从AI生成PPT到一键智能生成
人工智能·科技·aigc·powerpoint·软件
u01330870911 天前
PPT工具集
powerpoint
小众AI11 天前
pptx2md - 将PPT文件转换成Markdown
人工智能·powerpoint·ai编程