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

相关推荐
波点兔7 小时前
利用Python解析json生成PPT、xmind思维导图教程
json·powerpoint·音视频
百里香酚兰3 天前
【PPT学习笔记】使用PPT制作动画/手书/视频等作品的适配性和可能性?
笔记·学习·powerpoint
robinbird_3 天前
【超简单】1分钟解决ppt全文字体一键设置
powerpoint
2401_856648863 天前
解锁2024年PDF转PPT新技能,TOP4神器在手,职场晋升竟然如此简单
安全·pdf·编辑器·powerpoint
日里安3 天前
python办公自动化:使用`Python-PPTX` 嵌入媒体文件
java·前端·python·powerpoint·python-pptx
趣说科技4 天前
ai免费生成ppt软件有哪些?我推荐秒出PPT
powerpoint
小沈熬夜秃头中୧⍤⃝4 天前
在线演示文稿应用PPTist本地化部署并实现无公网IP远程编辑PPT
网络协议·tcp/ip·powerpoint
日里安5 天前
python办公自动化:使用`Python-PPTX`创建和操作表格
开发语言·python·powerpoint·python-pptx
m0_632544215 天前
误删的PPT怎么恢复回来?
powerpoint
红岸JD瞭望者5 天前
教育行业解决方案:智能PPT在教育行业的创新应用
powerpoint