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



我只展示了一张带有许多动画的幻灯片。一个形状被耦合到一个宏,该宏应该以另一种矩形形式更改文本

当我单击形状时,文本会发生更改,但只有当演示文稿再次显示时,更改才可见。此外,运行宏使幻灯片的演示从头开始!

我想要的是在单击链接到宏的形状时立即看到文本更改,并继续演示。。。

谢谢你的建议!!

这是宏的代码:

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

所以我们都清楚我们都在看什么,试试这个:

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

最新更新