Shape Arrays VBA

Joined
Feb 5, 2020
Messages
1
Reaction score
0
Hi I want to store a bunch of shapes in an array so that I can edit their properties with macros. I need to access them several times through several buttons which is why I want to use an array. Can I even store them as an array?

Public QuestionShapes(1 to 5) as Shape

'This macro is on the first slide which is just a title and initialises a few variables and scores before jumping to the main slide which is number 2.
Sub startButton()
Set QuestionShapes(1) As ActivePresentation.Slides(2).Shapes("QuestionBox1")
Set QuestionShapes(2) As ActivePresentation.Slides(2).Shapes("QuestionBox2")
Set QuestionShapes(3) As ActivePresentation.Slides(2).Shapes("QuestionBox1")
Set QuestionShapes(4) As ActivePresentation.Slides(2).Shapes("QuestionBox1")
Set QuestionShapes(5) As ActivePresentation.Slides(2).Shapes("DoneButtonShape")
End Sub

'This macro makes the hidden buttons appear
Sub QuestionButton()
For i = 1 To 5
QuestionShapes(i).Visible = msoTrue
Next
End Sub

'This macro makes the hidden buttons disappear
Sub DoneButton()
For i = 1 To 5
QuestionShapes(i).Visible = msoFalse
Next
End Sub

This works when I don't use the array (ActivePresentation.Slides(2).Shapes("DoneButtonShape").Visible = msoTrue) but not when I use the array and I don't know why. Any help would be great I am trying to make an activity for my English students.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top