使用 PowerPoint VBA 从 Kiosk 演示类型更改为演讲者演示类型
Using PowerPoint VBA to change from a Kiosk presentation type to a Speaker presentation type
我有一个 PowerPoint,里面装有 VBA 和很多幻灯片。当我是演示文稿的用户 运行 时,我希望能够通过按 {Page Down} 键手动推进幻灯片,但是,我希望 {Page Down} 键在任何其他用户正在播放时不起作用运行 演示文稿。
我知道以下内容:
- 我有一个函数可以很容易地 return 用户的名字,所以,我可以很容易地将当前用户与我自己进行比较,并根据匹配的 match/lack 执行代码。这里没问题。
- 我知道我可以使用以下方式设置演示文稿类型:
ActivePresentation.SlideShowSettings.ShowType = ppShowTypeSpeaker
。
- 我知道我可以使用以下方式设置幻灯片的前进方式:
ActivePresentation.SlideShowSettings.AdvanceMode = ppSlideShowManualAdvance
问题和我尝试过的事情:
- PowerPoint 启动后,使用 VBA 代码将 ShowType 的值从默认设置 ppShowTypeKiosk 更改为 ppShowTypeSpeaker 似乎并没有改变其余放映功能的方式。
- PowerPoint 启动后,使用 VBA 代码将 AdvanceMode 的值更改为 ppSlideShowManualAdvance 实际上并不能使我手动前进幻灯片(我仍然只能使用屏幕上的 ActiveX 按钮前进幻灯片幻灯片)。
- 我考虑过使用事件处理来捕获 SlideShowBegin 事件,但是,显然事件只能在代码为 Application 对象建立 link 之后才能捕获,并且使 link必须在通过单击已经 运行 幻灯片中的 ActiveX 控件(或类似的用户操作)运行的代码中发生,所以我很困惑如果没有带有 Auto_Open 的插件,SlideShowBegin 事件将如何被困住宏.
底线:PowerPoint VBA 代码是否有办法将幻灯片从展台模式切换到扬声器模式,以便可以手动推进幻灯片? (或者,其他一些方法可以让我手动推进幻灯片,同时防止所有其他用户手动推进幻灯片?)
感谢@SteveRindsberg,修复是 (a) 确定是否切换演示模式,然后,(b) 如果需要切换,运行 更改设置的代码,然后,(c) 以编程方式结束幻灯片,然后,(d) 以编程方式 运行 代码 re-start 幻灯片。
假定在 Kiosk 模式下 PowerPoint 默认已保存到 运行,这样标准用户无法使用 PageDown 或其他导航技术在幻灯片中移动;也就是说,幻灯片只能由程序员的 ActiveX 控件导航,这些控件使用 VBA 代码在幻灯片中移动。 (这对于 quiz-type 幻灯片等很方便)
具体来说,我有幻灯片 1,其中包含一个 ActiveX [确定] 按钮,用户可以单击该按钮以继续;基本上,幻灯片 1 是一张标题幻灯片,给出了 PowerPoint 的名称。单击 OK 按钮后,[OK] 按钮后面的代码会检查是否应允许用户将演示模式从默认的 Kiosk 模式更改为 Speaker 模式。这是幻灯片 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
然后,为了防止超级用户在幻灯片放映 re-start 时不得不查看第一张幻灯片两次,我在 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
对我来说,在幻灯片放映 re-start 秒之前单击 [确定] 按钮后,幻灯片 1 有很长的延迟(可能是 10 秒),但是,标准用户不会遇到延迟,所以我不不要介意等待——这可能与 VBA 代码和演示文稿中包含大量 ActiveX 控件的大量幻灯片有关——至少,这是我的猜测。
希望这对某人有所帮助!
我有一个 PowerPoint,里面装有 VBA 和很多幻灯片。当我是演示文稿的用户 运行 时,我希望能够通过按 {Page Down} 键手动推进幻灯片,但是,我希望 {Page Down} 键在任何其他用户正在播放时不起作用运行 演示文稿。
我知道以下内容:
- 我有一个函数可以很容易地 return 用户的名字,所以,我可以很容易地将当前用户与我自己进行比较,并根据匹配的 match/lack 执行代码。这里没问题。
- 我知道我可以使用以下方式设置演示文稿类型:
ActivePresentation.SlideShowSettings.ShowType = ppShowTypeSpeaker
。 - 我知道我可以使用以下方式设置幻灯片的前进方式:
ActivePresentation.SlideShowSettings.AdvanceMode = ppSlideShowManualAdvance
问题和我尝试过的事情:
- PowerPoint 启动后,使用 VBA 代码将 ShowType 的值从默认设置 ppShowTypeKiosk 更改为 ppShowTypeSpeaker 似乎并没有改变其余放映功能的方式。
- PowerPoint 启动后,使用 VBA 代码将 AdvanceMode 的值更改为 ppSlideShowManualAdvance 实际上并不能使我手动前进幻灯片(我仍然只能使用屏幕上的 ActiveX 按钮前进幻灯片幻灯片)。
- 我考虑过使用事件处理来捕获 SlideShowBegin 事件,但是,显然事件只能在代码为 Application 对象建立 link 之后才能捕获,并且使 link必须在通过单击已经 运行 幻灯片中的 ActiveX 控件(或类似的用户操作)运行的代码中发生,所以我很困惑如果没有带有 Auto_Open 的插件,SlideShowBegin 事件将如何被困住宏.
底线:PowerPoint VBA 代码是否有办法将幻灯片从展台模式切换到扬声器模式,以便可以手动推进幻灯片? (或者,其他一些方法可以让我手动推进幻灯片,同时防止所有其他用户手动推进幻灯片?)
感谢@SteveRindsberg,修复是 (a) 确定是否切换演示模式,然后,(b) 如果需要切换,运行 更改设置的代码,然后,(c) 以编程方式结束幻灯片,然后,(d) 以编程方式 运行 代码 re-start 幻灯片。
假定在 Kiosk 模式下 PowerPoint 默认已保存到 运行,这样标准用户无法使用 PageDown 或其他导航技术在幻灯片中移动;也就是说,幻灯片只能由程序员的 ActiveX 控件导航,这些控件使用 VBA 代码在幻灯片中移动。 (这对于 quiz-type 幻灯片等很方便)
具体来说,我有幻灯片 1,其中包含一个 ActiveX [确定] 按钮,用户可以单击该按钮以继续;基本上,幻灯片 1 是一张标题幻灯片,给出了 PowerPoint 的名称。单击 OK 按钮后,[OK] 按钮后面的代码会检查是否应允许用户将演示模式从默认的 Kiosk 模式更改为 Speaker 模式。这是幻灯片 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
然后,为了防止超级用户在幻灯片放映 re-start 时不得不查看第一张幻灯片两次,我在 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
对我来说,在幻灯片放映 re-start 秒之前单击 [确定] 按钮后,幻灯片 1 有很长的延迟(可能是 10 秒),但是,标准用户不会遇到延迟,所以我不不要介意等待——这可能与 VBA 代码和演示文稿中包含大量 ActiveX 控件的大量幻灯片有关——至少,这是我的猜测。
希望这对某人有所帮助!