查找PPT中某种字体的全部对应文字

本文章的目的是找到某种字体的文字,而不是替换某种字体的文字,也不是将某种字体全部替换为另外一种文字。

第一步在PPT中按下ALT+F11
出现以下窗口
在这里插入图片描述
第二步:点击插入->模块
在这里插入图片描述
第三步将以下代码输入到窗体中

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,运行后会弹出新的窗口
输入字体后,会列出所有的文字位置
在这里插入图片描述
在这里插入图片描述

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-12 20:16:02       67 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-12 20:16:02       71 阅读
  3. 在Django里面运行非项目文件

    2024-07-12 20:16:02       58 阅读
  4. Python语言-面向对象

    2024-07-12 20:16:02       69 阅读

热门阅读

  1. git reset hard和soft的使用和区别

    2024-07-12 20:16:02       19 阅读
  2. 目前分布式光纤测温系统的主流架构有哪些?

    2024-07-12 20:16:02       19 阅读
  3. docker pull 报错:missing signature key,docker版本问题

    2024-07-12 20:16:02       18 阅读
  4. 第六篇:Python元组:不可变序列的魅力

    2024-07-12 20:16:02       18 阅读
  5. Linux rpm和ssh损坏修复

    2024-07-12 20:16:02       21 阅读
  6. 【cnocr的安装使用】

    2024-07-12 20:16:02       20 阅读
  7. c#获取本机的MAC地址(附源码)

    2024-07-12 20:16:02       20 阅读