如何使用 VBA 删除 PowerPoint 中的双空行?

How to remove double empty lines in PowerPoint using VBA?

我正在将数据从 MS Access 导出到 MS PowerPoint,其中一部分数据是包含多个段落的文本字段(长),就像在单个字段的行之间点击 ENTER 一样。 这样的结果,导出后出现的各种现象我都想搞清楚。最令人不安的问题之一是 Powerpoint 幻灯片中出现的控制字符和特殊字符。

我主要尝试使用 :search and replace" 方法,例如

shp.TextFrame.TextRange.Text = Replace(shp.TextFrame.TextRange.Text, "this", "that")

但我不知道如何解决双空行问题。而且,似乎有一整套换行符和组合(见This SO question),我不知道有哪些。 在 MS Word 中它相对容易一些,因为它的搜索和替换功能支持这些特殊字符。在 Powerpoint 中不是这样。

谢谢

试试这个宏来删除多个空行

Function removeMultiBlank(s As String) As String
    With CreateObject("VBScript.RegExp")
        .Global = True
        .MultiLine = True
        .IgnoreCase = True
        .Pattern = "^\s"

        removeMultiBlank= .Replace(s, "")
    End With
End Function

像使用它

With shp.TextFrame.TextRange
    .Text = removeMultiBlank(.Text)
End With