我有一个脚本只能循环播放一张幻灯片并获取以文字形式写的文字
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数组调整代码,但是我收到错误。
我正在寻找一个脚本,它给我一条包含所有幻灯片中字符数的消息
请帮助我。
答案 0 :(得分:0)
尝试嵌套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