2

ここで何が問題なのか完全に理解できません。最後の debug.print 行にオブジェクト変数が設定されていません。注意 - ループ内の debug.print 行は正常に出力され、配列内にあるはずの 3 つの形状があります (ループの最後で 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
4

1 に答える 1