0

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
  • First, there's no need for the Else clause or the command following it, since that just sets the text to whatever it's already set to. As to making the changes appear, it's sometimes necessary to jump the view to a different slide then back; in your case, you'd need to add another (hidden) slide to have someplace to jump to. Further, it can sometimes be necessary to add another shape to your slide, even one that's off-slide, so not visible to user, then delete it in order to force PPT to refresh the view of the slide you're working on. – Steve Rindsberg Dec 25 '20 at 18:01
  • @Steve Tried adding this dummy shape and delete it ... to no avail. Upon running the macro the slide restarts with the first animation and doesn't 'proceed' where the macro started. I included this code in... `Set shp = myDocument.Shapes.AddShape(msoShapeRectangle, -250, -350, 100, 200) With shp .Name = "Rechthoek 16" End With .Shapes("Rechthoek 16").Delete` – user1969845 Dec 26 '20 at 19:29

1 Answers1

0

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
Steve Rindsberg
  • 14,442
  • 1
  • 29
  • 34
  • Thanks again, but it doesn't work... Here you can find the presentation (only one slide with some animations...) [link](https://1drv.ms/p/s!AuCtA1xw6Hv63TdUApBwbPneTEJZ?e=lBn0qy) – user1969845 Jan 01 '21 at 08:48
  • Thanks ... but it's not clear which shape is linked to the macro. I'm too lazy to look at all of them one by one ;-) – Steve Rindsberg Jan 01 '21 at 18:06
  • Ah, OK, sorry about that! When running the presentation, one of the animations will show a blue rectangle in the low right corner of the slide: the macro is linked to that shape. The shape it influences is the rectangle with the text 'Replay O(A) '. – user1969845 Jan 03 '21 at 09:06
  • Thanks. I made one correction to the code I posted above but it still doesn't work. I also modified your file to make the macro work on a newly inserted shape, and it STILL misbehaves. With your permission, I'd like to send this to some people I know at Microsoft. – Steve Rindsberg Jan 03 '21 at 19:42
  • Feel free to send this to who can help, thanks very much! – user1969845 Jan 05 '21 at 13:14