【发布时间】:2015-07-28 20:10:33
【问题描述】:
无法完全弄清楚这里出了什么问题。 我得到一个未为最后一个 debug.print 行设置的对象变量。 注意 - 循环中的 debug.print 行打印良好,并且数组中应该有三个形状(并且 i 在循环结束时位于 3 处)。 我想我可能只是不明白数组/变量设置是如何工作的,我是 VBA 新手(不过我确实有编程经验)。
Dim allShapes As Shapes
Set allShapes = ActivePresentation.Slides(11).Shapes
Dim textShapes() As Shape
ReDim textShapes(0 To 2)
i = 0
For Each thisShape In allShapes
If thisShape.HasTextFrame Then
If thisShape.TextFrame.HasText Then
Debug.Print thisShape.TextFrame.TextRange.Text
Set textShapes(i) = thisShape
i = i + 1
ReDim textShapes(0 To i) As Shape
End If
End If
Next thisShape
ReDim textShapes(0 To i - 1)
Debug.Print textShapes(1).TextFrame.TextRange.Text
【问题讨论】:
标签: vba powerpoint