Question

I have a sub to import an image and place it behind a square which then disappears when clicked (disappear animation triggered on click).

But after I run the sub the trigger stops working. After a lot of searching I found it is caused by the section that changes the Z order. If I remove this part of the sub everything works fine but unfortunately that is not much use as the image is in front of the square that is supposed to reveal it.

I'm pretty new to this so if anyone can shed any light on this (or even better suggest a solution!) I would be very grateful.

Thanks

Matt

 Dim mySld As Slide
 Dim myShp As ShapeRange
 Dim i As Integer

 Set mySld = ActivePresentation.Slides.FindBySlideID(256)

 Set myShp = mySld.Shapes.Paste

    With myShp
        .Name = "Quiz_Image_" & i
        .Left = 70
        .Top = 75
        .LockAspectRatio = msoTrue
        .Width = 425
        .ZOrder msoSendToBack
    End With

If myShp.Height > 275 Then
    myShp.Height = 275
End If
Was it helpful?

Solution

Yes, setting the ZOrder, resets the trigger. The only option that I can think of (unless someone else points out a better solution) is to initiate the animation from the code it self using .AnimationSettings. For example

Option Explicit

Sub Sample()
    Dim mySld As Slide
    Dim myShp As ShapeRange
    Dim i As Integer

    Set mySld = ActivePresentation.Slides(1)

    Set myShp = mySld.Shapes.Paste

    With myShp
        .Name = "Quiz_Image_" & i
        .Left = 70
        .Top = 75
        .LockAspectRatio = msoTrue
        .Width = 425
        .ZOrder msoSendToBack
    End With

    If myShp.Height > 275 Then
        myShp.Height = 275
    End If

    mySld.Shapes("Shape Name").AnimationSettings.Animate
End Sub

EDIT

Also see this interesting read

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top