简体   繁体   English

Powerpoint VBA 为什么运行宏会使演示文稿从头开始?

[英]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...我想要的是让 textchange 在单击链接到宏的形状后立即可见,并让演示文稿继续......

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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