首页 文章

使用PowerPoint VBA从Kiosk演示文稿类型更改为演讲者演示文稿类型

提问于
浏览
0

我有一个装有VBA的PowerPoint和很多幻灯片 . 当我是运行演示文稿的用户时,我希望能够通过按键手动推进幻灯片,但是,当任何其他用户正在运行演示文稿时,我希望键不起作用 .

我知道以下内容:

  • 我有一个很容易返回用户名的功能,因此,我可以轻松地将当前用户与自己进行比较,并根据匹配/缺少匹配执行代码 . 这里没问题 .

  • 我知道我可以使用以下方式设置演示文稿类型: ActivePresentation.SlideShowSettings.ShowType = ppShowTypeSpeaker .

  • 我知道我可以使用以下方式设置幻灯片的推进方式: ActivePresentation.SlideShowSettings.AdvanceMode = ppSlideShowManualAdvance

我试过的问题和事情:

  • PowerPoint启动后,使用VBA代码将ShowType的值从ppShowTypeKiosk的默认设置更改为ppShowTypeSpeaker似乎不会改变show其余部分的功能 .

  • PowerPoint启动后,使用VBA代码将AdvanceMode的值更改为ppSlideShowManualAdvance实际上并不能让我手动前进幻灯片(我仍然只能使用幻灯片上的ActiveX按钮推进幻灯片) .

  • 我曾考虑使用事件处理来捕获SlideShowBegin事件,但是,显然事件只能在代码 Build 到Application对象的链接后被捕获,并且必须在通过单击ActiveX控件运行的代码中发生该链接(或类似的用户操作)在已经运行的幻灯片中,所以我很困惑如何在没有带AutoInOpen宏的AddIn的情况下捕获SlideShowBegin事件 .

Bottom line: PowerPoint VBA代码是否有办法将幻灯片从自助服务终端切换到扬声器模式,以便可以手动提升幻灯片? (或者,其他一些方法可以让我手动推进幻灯片,同时阻止所有其他用户手动推进幻灯片?)

1 回答

  • 0

    感谢@SteveRindsberg,修复方法是(a)确定是否切换演示模式,然后,(b)如果需要切换,运行代码更改设置,然后,(c)以编程方式结束幻灯片放映,然后,(d)以编程方式运行代码以重新开始幻灯片放映 .

    假设PowerPoint已保存为默认在Kiosk模式下运行,因此标准用户无法使用PageDown或其他导航技术来浏览幻灯片;也就是说,幻灯片只能由程序员的ActiveX控件导航,这些控件使用VBA代码在幻灯片中移动 . (这对于测验类幻灯片等很方便)

    具体来说,我有幻灯片1,其上包含一个ActiveX [确定]按钮,用户被指示单击该按钮以继续;基本上,幻灯片1是一个 Headers 幻灯片,它给出了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控件的大量幻灯片有关 - 至少,这是我的猜测 .

    希望这可以帮助别人!

相关问题