遍历所有幻灯片并获取 powerpoint 中的字符数

Iterate through all slides and get the count of characters in powerpoint

我有一个脚本只循环遍历一张幻灯片,并得到写在形状中的文本

Sub Sample()
Dim textShapes() As Shape, i as Long

ReDim textShapes(0 To 2)

i = 0

For Each thisShape In ActivePresentation.Slides(1).Shapes
    If thisShape.HasTextFrame Then
        If thisShape.TextFrame.HasText Then
           Set textShapes(i) = thisShape
           i = i + 1
           ReDim Preserve textShapes(0 To i) As Shape
        End If
     End If
Next thisShape

Debug.Print textShapes(1).TextFrame.TextRange.Text End Sub

但是,我想遍历所有幻灯片并从所有幻灯片的形状和占位符中获取字符数

希望可以使用 redim preserve array 调整代码,但出现错误。

我正在寻找一个脚本,该脚本会向我提供包含所有幻灯片中字符数的消息

请帮助我。

尝试嵌套 for-each:

For Each slide In ActivePresentation.Slides
    For Each thisShape In slide.Shapes
        If thisShape.HasTextFrame Then
            If thisShape.TextFrame.HasText Then 
               Set textShapes(i) = thisShape
               i = i + 1
               ReDim Preserve textShapes(0 To i) As Shape   
            End If
        End If
    Next thisShape
Next slide