感謝@SteveRindsberg,解決方法是(a)確定是否切換演示模式,然後,(b)如果需要開關,運行代碼改變設置,然後,(c)以編程方式結束幻燈片,然後,(d)以編程方式運行代碼以重新開始幻燈片。
假定PowerPoint演示已保存默認在Kiosk模式下運行,以使標準用戶不能使用下頁或其它導航技術通過滑動移動;也就是說,幻燈片只能由使用VBA代碼的程序員的ActiveX控件來瀏覽幻燈片。 (這對於測驗類型的幻燈片等是很方便的)
具體來說,我有幻燈片1,其中包含一個ActiveX [確定]按鈕,用戶指向點擊以繼續;基本上,幻燈片1是一個標題幻燈片,它給出了PowerPoint的名稱。點擊OK按鈕後,[OK]按鈕後面的代碼將檢查是否允許用戶將演示模式從默認Kiosk模式更改爲Speaker模式。下面是在幻燈片1的[OK]按鈕後面的代碼:
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控件有關 - 至少,這是我猜。
希望這可以幫助別人!
來源
2016-07-26 13:44:08
DRC
您是否嘗試過編碼a)結束幻燈片放映,b)更改幻燈片放映模式,然後c)重新開始放映幻燈片。 –
啊!當然!謝謝@SteveRindsberg。那就是訣竅。在結束/重新開始播放幻燈片的代碼與實際重新啓動時間之間存在一段荒謬的長時間延遲,但是* *會起作用。請提交答案,我會將其標記爲答案。 – DRC
很高興幫助,但更好的是,提交工作代碼作爲答案,以便我們可以更直接地幫助其他人。 –