G
Guest
I am trying to create an array of shapes (while presentation is running)
which have been given specific names (MyShape0, MyShape1, MyShape2...) on a
named slide ("MySlide").
I have tried something like the following but I keep getting runtime errors:
'Global array variable:
Dim MyShapeArray(0 to 11) as Shape
'From within a subroutine in the same module:
With ActivePresentation.Slides("MySlide")
MyShapeArray(0) = .Shapes("MyShape0")
MyShapeArray(1) = .Shapes("MyShape1")
MyShapeArray(2) = .Shapes("MyShape2")
MyShapeArray(3) = .Shapes("MyShape3")
MyShapeArray(4) = .Shapes("MyShape4")
MyShapeArray(5) = .Shapes("MyShape5")
MyShapeArray(6) = .Shapes("MyShape6")
MyShapeArray(7) = .Shapes("MyShape7")
MyShapeArray(8) = .Shapes("MyShape8")
MyShapeArray(9) = .Shapes("MyShape9")
MyShapeArray(10) = .Shapes("MyShapeA")
MyShapeArray(11) = .Shapes("MyShapeB")
End With
For i = 0 To 11
MyShapeArray(i).TextFrame.TextRange.Text = "00"
Next i
The code above gives me an error stating that an object or with variable has
not been set with the "MyShapeArray(0) = .Shapes("MyShape0")" line
highlighted.
Any idea what I'm doing wrong? I have also tried this without using a With
block, by spelling out the full reference to the shape on each line, but that
generates the same error.
which have been given specific names (MyShape0, MyShape1, MyShape2...) on a
named slide ("MySlide").
I have tried something like the following but I keep getting runtime errors:
'Global array variable:
Dim MyShapeArray(0 to 11) as Shape
'From within a subroutine in the same module:
With ActivePresentation.Slides("MySlide")
MyShapeArray(0) = .Shapes("MyShape0")
MyShapeArray(1) = .Shapes("MyShape1")
MyShapeArray(2) = .Shapes("MyShape2")
MyShapeArray(3) = .Shapes("MyShape3")
MyShapeArray(4) = .Shapes("MyShape4")
MyShapeArray(5) = .Shapes("MyShape5")
MyShapeArray(6) = .Shapes("MyShape6")
MyShapeArray(7) = .Shapes("MyShape7")
MyShapeArray(8) = .Shapes("MyShape8")
MyShapeArray(9) = .Shapes("MyShape9")
MyShapeArray(10) = .Shapes("MyShapeA")
MyShapeArray(11) = .Shapes("MyShapeB")
End With
For i = 0 To 11
MyShapeArray(i).TextFrame.TextRange.Text = "00"
Next i
The code above gives me an error stating that an object or with variable has
not been set with the "MyShapeArray(0) = .Shapes("MyShape0")" line
highlighted.
Any idea what I'm doing wrong? I have also tried this without using a With
block, by spelling out the full reference to the shape on each line, but that
generates the same error.