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

相关推荐
2501_930707789 小时前
使用C#代码更改 PowerPoint 幻灯片大小
开发语言·c#·powerpoint
dagouaofei12 小时前
PPT AI生成实测报告:哪些工具值得长期使用?
人工智能·python·powerpoint
轻竹办公PPT17 小时前
汇总12款Word生成PPT工具,哪款更适合日常汇报?
人工智能·powerpoint
小毅&Nora19 小时前
【后端】【工具】从 “Vibe PPT“ 到 “蕉幻“:一个原生 AI PPT 生成应用的深度解析
人工智能·powerpoint
EAIReport21 小时前
基于AI的全国蔬菜供应与价格预测PPT自动化生成方案
人工智能·自动化·powerpoint
CodeCraft Studio1 天前
国产化PPT处理控件Spire.Presentation教程:使用Python将图片批量转换为PPT
python·opencv·powerpoint·ppt文档开发·ppt组件库·ppt api
dagouaofei1 天前
AI自动生成PPT工具对比分析,效率差距明显
人工智能·python·powerpoint
dagouaofei2 天前
全面整理6款文档生成PPT工具,PDF转PPT不再难
python·pdf·powerpoint
dagouaofei2 天前
文档生成PPT到底快不快?PDF转PPT工具实测分析
python·pdf·powerpoint
小笔学长3 天前
毕业论文答辩 PPT:从内容到呈现的全流程设计指南
人工智能·powerpoint