Search code examples
vbaanimationtriggerspowerpointeffects

VB PowerPoint, showing a picture when several others are clicked


I've been learning today some VBA basics to apply in powerpoint, but I have some experience in some other languages. As title says, I want a picture to be shown after I click on 3 other pictures before that. When any of this 3 pictures are clicked, they trigger a tick to be shown above that image, and I'm using those as a refer to code my macro. I have the following:

Sub Condicion()

    Set Diapo14 = ActivePresentation.Slides(14)
    If Diapo14.Shapes("tick1").Visible = True And _
       Diapo14.Shapes("tick2").Visible = True And _
       Diapo14.Shapes("tick3").Visible = True Then

        Diapo14.Shapes("FlechaDer").Visible = True

    End If
End Sub

I have the picture I want to show (FlechaDer) with a disappear effect as soon as the slide starts, but no matter what I do, when I test the slide, the picture is always there. Maybe I'm not applying the correct approach, hope someone can help me. I'm not even sure if this can be done in PowerPoint.


Solution

  • I got it working with the code below. I had to replace the "ticks" in the If cycle, and instead of them I used the pictures that once clicked popped up the ticks:

    Sub Can12()
        Set Diapo12 = ActivePresentation.Slides(12)
        Diapo12.Shapes("Can").Visible = False
        If Diapo12.Shapes("Can").Visible = False And Diapo12.Shapes("Wool").Visible = False And Diapo12.Shapes("Pencil").Visible = False Then
            Diapo12.Shapes("FlechaDer").Visible = True
        End If
    End Sub
    
    Sub Wool12()
        Set Diapo12 = ActivePresentation.Slides(12)
        Diapo12.Shapes("Wool").Visible = False
        If Diapo12.Shapes("Can").Visible = False And Diapo12.Shapes("Wool").Visible = False And Diapo12.Shapes("Pencil").Visible = False Then
            Diapo12.Shapes("FlechaDer").Visible = True
        End If
    End Sub
    
    Sub Pencil12()
        Set Diapo12 = ActivePresentation.Slides(12)
        Diapo12.Shapes("Pencil").Visible = False
        If Diapo12.Shapes("Can").Visible = False And Diapo12.Shapes("Wool").Visible = False And Diapo12.Shapes("Pencil").Visible = False Then
            Diapo12.Shapes("FlechaDer").Visible = True
        End If
    End Sub
    

    It worked fine on activating an animation (Right Arrow popping up) when all 3 items were clicked. I had to add the corresponding macro to the picture. (Can, wool and pencil)