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

相关推荐
kaka.liulin -study1 天前
EmberTrace AI | NoteBook Mode :DeepPPT Gen 智能PPT生成
人工智能·语言模型·powerpoint
小爷毛毛(卓寿杰)1 天前
SlideFlow: AI 驱动的 PPT 自动化生成引擎
人工智能·自动化·powerpoint·大语言模型
LAM LAB1 天前
【VBA/ppt】设置选中字体为红色
powerpoint·vba·wps
weixin_456907411 天前
使用 html为 ppt 文档添加文本像素格的实用方法
html·tensorflow·powerpoint
老兵发新帖1 天前
技术架构图drawio到PPT
powerpoint·draw.io
老兵发新帖2 天前
Markdown转PPT工具实践总结
powerpoint
K姐研究社2 天前
免费Nano Banana 制作PPT,SpeedAI 智能体一句话生成
人工智能·aigc·powerpoint
chatexcel2 天前
ChatExcel实测:多模态识别自动做表 + 对话式数据分析 + 一键生成PPT
人工智能·powerpoint
小真zzz3 天前
AI美化年终总结PPT的具体操作方案
人工智能·ai·powerpoint·ppt·chatppt
开开心心_Every4 天前
PDF转图片工具推荐:免费支持批量转换
linux·运维·服务器·spring boot·edge·pdf·powerpoint