我编写的Excel VBA代码将运行PowerPoint幻灯片演示文稿,并且演示文稿设置为在一定时间后自动并连续前进到下一张幻灯片。演示文稿运行10秒后,代码暂停PowerPoint演示文稿。所有这些代码都正常工作。但是,我很难使用VBA代码重新启动幻灯片演示,我无法弄清楚原因。我确实添加了" Microsoft PowerPoint 15.0对象库"参考
这是我的代码:
Sub Code()
Application.Calculation = xlManual
Dim pApp As PowerPoint.Application
Dim pPres As PowerPoint.Presentation
Dim pFile As PowerPoint.Presentation
Dim strPresPath As String
strPresPath = "this is where I put the file path"
Set pApp = CreateObject("PowerPoint.Application")
Set pFile = pApp.Presentations(strPresPath)
Set pPres = pApp.ActivePresentation
pPres.SlideShowSettings.Run
Wait (10)
pPres.SlideShowWindow.View.State = ppSlideShowPaused
Wait (5)
pPres.SlideShowWindow.View.State = ppSlideShowRunning
这是" Wait"的代码。被称为的函数:
Function Wait(lngSeconds As Long)
Application.Wait DateAdd("s", lngSeconds, Now)
End Function
有没有人想知道为什么我无法重新启动幻灯片演示文稿?
提前谢谢。