我有一个装有VBA的PowerPoint和很多幻灯片。当我是运行演示文稿的用户时,我希望能够通过按{Page Down}键手动推进幻灯片,但是,当任何其他用户正在运行演示文稿时,我希望{Page Down}键不起作用。
我知道以下内容:
ActivePresentation.SlideShowSettings.ShowType = ppShowTypeSpeaker
。ActivePresentation.SlideShowSettings.AdvanceMode = ppSlideShowManualAdvance
问题和我尝试的事情:
底线: PowerPoint VBA代码是否有办法将幻灯片从自助服务终端切换到扬声器模式,以便可以手动提升幻灯片? (或者,其他一些方法可以让我手动推进幻灯片,同时阻止所有其他用户手动推进幻灯片?)
答案 0 :(得分:0)
感谢@SteveRindsberg,修复方法是(a)确定是否切换演示模式,然后,(b)如果需要切换,运行代码更改设置,然后,(c)以编程方式结束幻灯片放映,然后,(d)以编程方式运行代码以重新开始幻灯片放映。
默认情况下,PowerPoint已保存为以Kiosk模式运行,因此标准用户无法使用PageDown或其他导航技术来浏览幻灯片;也就是说,幻灯片只能由程序员的ActiveX控件导航,这些控件使用VBA代码在幻灯片中移动。 (这对于测验类幻灯片等很方便。)
具体来说,我有幻灯片1,其中包含一个ActiveX [确定]按钮,用户可以点击该按钮以便继续;基本上,幻灯片1是一个标题幻灯片,它给出了PowerPoint的名称。单击确定按钮后,[确定]按钮后面的代码将检查是否允许用户将演示模式从默认的Kiosk模式更改为扬声器模式。这是幻灯片1中[确定]按钮背后的代码:
Private Sub cmdFeedbackOK_Click()
'handle the click of the OK button on the feedback which will move to the next slide or exit if the wrong OS or Office Version (based on text associated with the [OK] button
'check for superuser
If LCase(Environ("UserName")) = "{Windows username who is a superuser}" And ActivePresentation.SlideShowSettings.ShowType <> ppShowTypeSpeaker Then 'this will check to be sure that we have not already changed the ShowType (which will have changed if the user opts to switch modes and the PPTX has re-started)
'superuser, so, change to Speaker mode
If MsgBox("Do you want to switch to Speaker view instead of Kiosk view so you can use PageDown?", vbYesNo + vbDefaultButton1, "Use PageDown?") = vbYes Then
ActivePresentation.SlideShowSettings.ShowType = ppShowTypeSpeaker 'switch from Kiosk to Speaker mode so that PageDown key will work
ActivePresentation.SlideShowSettings.AdvanceMode = ppSlideShowManualAdvance 'switch to allow PageDown to manually advance the slides
ActivePresentation.SlideShowWindow.View.Exit 'exit the show because the change in play mode and advance mode will not take effect until the show is started again
ActivePresentation.SlideShowSettings.Run 'restart the show; code in the OnSlideShowPageChange will get triggered to skip this first slide if the user has restarted the show
Exit Sub
End If
End If
ActivePresentation.SlideShowWindow.View.Next 'move to next slide
End Sub
然后,为了防止超级用户在幻灯片重新启动时必须两次查看第一张幻灯片,我将以下代码添加到OnSlideShowPageChange事件中:
SlideName = ActivePresentation.SlideShowWindow.View.Slide.Name
If SlideName = "sldTitle" Then 'we're on the first slide
If ActivePresentation.SlideShowSettings.ShowType = ppShowTypeSpeaker Then 'this will be true if the Windows user is me (see code in Slide1), and, since I've already seen that slide, just go to the next slide
ActivePresentation.SlideShowWindow.View.Next 'skip the first slide for superuser
'execute other code as desired
'use Exit Sub here if the code below does not need to run for the superuser
End If
End If
'execute other code as desired here, e.g., code for standard users
对我来说,在幻灯片重新开始之前单击[确定]按钮后,幻灯片1会给出一个很长的延迟(可能是10秒),但是,标准用户没有遇到延迟,所以我不介意等待 - - 这可能与VBA代码和演示文稿中包含大量ActiveX控件的大量幻灯片有关 - 至少,这是我的猜测。
希望这可以帮助别人!