简体   繁体   中英

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM