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

相关推荐
不坑老师2 天前
利用不坑盒子在WPS中插入网页,放映的电脑无需安装插件,直接就能显示网页!
microsoft·word·powerpoint·wps
Juvenile* (逝年)4 天前
工作汇报和技术分享PPT如何高效制作?我的实用经验
powerpoint
ChatPPT_YOO4 天前
告别手搓PPT:实测四款免费AI生成工具
人工智能·信息可视化·powerpoint·ai生成ppt·ppt制作
caiyueloveclamp4 天前
便宜好用AIPPT推荐TOP8【2025最新】
大数据·人工智能·powerpoint·ai生成ppt·aippt·免费会员
Jet45055 天前
玩转ChatGPT:Kimi OK Computer PPT制作
人工智能·powerpoint·kimi·ok computer
spencer_tseng5 天前
Custom Animations for PPT (PowerPoint)
powerpoint·ppt·office
勘察加熊人7 天前
python+ai智能根据doc教案文档生成ppt
人工智能·python·powerpoint
spencer_tseng7 天前
PPT WPS ERROR +mn-ea
powerpoint·wps
会飞的小菠菜7 天前
大量PPT文件怎么快速转换成JPG格式的长图
powerpoint·合并·拼接·幻灯片·长图片
会飞的小菠菜8 天前
怎么将很多ppt批量转换成pptx?图文操作指南
powerpoint·ppt·批量·格式转换·pptx