2016-07-22 95 views
0

我有用VBA加載的PowerPoint和不少幻燈片。當我是用戶運行演示文稿時,我希望能夠通過按{Page Down}鍵手動推送幻燈片,但是,我希望在任何其他用戶正在運行演示文稿時{Page Down}鍵不起作用。使用PowerPoint VBA將Kiosk演示文稿類型更改爲Speaker演示文稿類型

我瞭解以下內容:

  1. 我有,很容易將返回用戶名的功能,所以,我可以很容易地根據匹配/缺乏的當前用戶比較自己和執行代碼比賽。這裏沒問題。
  2. 我知道我可以使用以下設置演示文稿類型:ActivePresentation.SlideShowSettings.ShowType = ppShowTypeSpeaker
  3. 我知道我可以設置幻燈片通過使用先進的方法:使用VBA代碼來改變

    1. 一旦PowerPoint中開始,:ActivePresentation.SlideShowSettings.AdvanceMode = ppSlideShowManualAdvance

    的問題和事情,我已經試過從ppShowTypeKiosk默認設置到ppShowTypeSpeaker的ShowType的值似乎沒有改變其他節目功能的方式。

  4. 一旦PowerPoint時開始,使用VBA代碼來改變AdvanceMode到ppSlideShowManualAdvance價值實際上並沒有使我能夠手動前進的幻燈片(我仍然只能夠提前在幻燈片上使用ActiveX按鈕幻燈片)。
  5. 我曾想過使用事件處理捕獲SlideShowBegin事件,但是,顯然一旦代碼已經建立了鏈接到應用程序對象事件,只能困,並且,使該鏈接在通過點擊一個運行的代碼發生在已經運行的幻燈片中使用ActiveX控件(或類似的用戶操作),所以我很困惑SlideShowBegin事件如果沒有帶有Auto_Open宏的AddIn就會被捕獲。

底線:有PowerPoint的VBA代碼的方式,從亭揚聲器模式切換的幻燈片,這樣幻燈片可以手動前進? (或者,使我能夠手動推進幻燈片,同時防止所有其他用戶手動推進幻燈片的其他方法?)

+1

您是否嘗試過編碼a)結束幻燈片放映,b)更改幻燈片放映模式,然後c)重新開始放映幻燈片。 –

+0

啊!當然!謝謝@SteveRindsberg。那就是訣竅。在結束/重新開始播放幻燈片的代碼與實際重新啓動時間之間存在一段荒謬的長時間延遲,但是* *會起作用。請提交答案,我會將其標記爲答案。 – DRC

+0

很高興幫助,但更好的是,提交工作代碼作爲答案,以便我們可以更直接地幫助其他人。 –

回答

0

感謝@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控件有關 - 至少,這是我猜。

希望這可以幫助別人!

+0

上述內容適用於* PPTM *文件,但它不適用於* PPSM *文件,因爲當* PPSM *文件終止時,它將被刪除並且無法重新啓動(顯然)。如果有人知道如何添加VBA實時代碼以將Kiosk * PPSM *更改爲使用手動高級類型顯示爲揚聲器顯示,那會更好。 – DRC

相關問題