简体   繁体   English

遍历所有幻灯片并获得PowerPoint中的字符数

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

I have a script to loop through only one slide and get the text written in the shape 我有一个脚本可以循环浏览一张幻灯片,并以文字形式写出文字

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

However, I want to loop through all slides and get the count of characters from shapes and placeholders of all slides 但是,我想遍历所有幻灯片并从所有幻灯片的形状和占位符中获取字符数

Hope the code can be tweaked with redim preserve array but i get an error. 希望代码可以使用redim保留数组进行调整,但出现错误。

Am looking for a script which gives me message with count of characters in all slides 我正在寻找一个脚本,该脚本可以向我传达所有幻灯片中的字符数信息

Please help me on the same. 请同样帮我。

try nested 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM