Powerpoint VBA why does running a macro make the presentation start from the start again?

159 Views Asked by At

I have a presentation of only one slide with a number of animations. A shape is coupled to a macro that is supposed to change the text in another rectangular form.

When I click the shape the text is changed but the change is only visible when the presentation is shown again. In addition, running the macro makes the presentation of the slide to start from the beginning!

What I want is for the textchange to be visible immediately upon clicking the shape that is linked to the macro and for the presentation to continue ...

Thanks for any suggestion !!

Here is the code of the macro:

Sub PastekstAan()
Set myDocument = ActivePresentation.Slides(1)
With myDocument.Shapes("Actieknop: Aangepast 8").TextFrame
    If .TextRange.Text = "Replay O(A)" Then
        .TextRange.Text = "Hallo"
    Else
        .TextRange.Text = "Replay O(A)"
    End If
End With
End Sub
1

There are 1 best solutions below

5
Steve Rindsberg On

So we're clear what we're both looking at, try this:

Sub PastekstAan()
Dim shp as Shape 
With ActivePresentation.Slides(1).Shapes("Actieknop: Aangepast 8").TextFrame
    If .TextRange.Text = "Replay O(A)" Then
        .TextRange.Text = "Hallo"
    End If
End With

set shp = ActivePresentation.Slides(1).Shapes.AddShape(msoShapeRectangle, -250, -350, 100, 200)
shp.Delete

' Try it with and without this, as going to the slide might
' reset the animation 
SlideShowWindows(1).View.GotoSlide(1)

End Sub