[英]Powerpoint 2010 - broadcast.start()
我想創建一個Powerpoint幻燈片,該幻燈片每5分鍾從源頭自動更新一次,然后啟動向網站的廣播服務(&不斷循環以刷新內容)。
我嘗試使用下面的代碼開始廣播,但始終出現運行時錯誤:“客戶端:將請求加載到SoapReader中失敗。”
Sub ShowIt()
Application.ActivePresentation.SlideShowSettings.Run
Application.ActivePresentation.Broadcast.Start ("https://bn1-broadcast.officeapps.live.com/")
DoEvents
End Sub
broadcast.start()如何工作?
這將以編程方式復制UI,但我想您不想這樣做,因為它需要用戶交互:
Application.CommandBars.ExecuteMso "BroadcastSlideShow"
兩個半有用的鏈接可能會有所幫助,盡管正如PatricK所指出的那樣,[帶有有效示例]的文檔似乎找不到:
MSDN上的廣播方法和屬性請注意,“其他版本”鏈接中2010年的子集較小。
我什至沒有得到你的幫助,並且得到了錯誤“對象“廣播”的方法“開始”失敗”。 然后,我通過PowerPoint 2016 UI(幻燈片顯示/在線演示)開始了廣播會話,然后在“即時”窗口中使用以下命令返回服務URL:
?ActivePresentation.Broadcast.PresenterServiceUrl
它返回了帶有asmx文件引用的本地化域:
https://ie1-broadcast.officeapps.live.com/m/present_2_0.asmx
但是,將其與.Start方法一起使用仍會返回相同的錯誤。 我想知道是否需要做一些准備工作(如使用UI時所見),例如保存到OneDrive位置。
使用PowerPoint 2016(PC),我設法連接到Present Online服務,並使用WinAPIs for VBA線程獨立計時器啟動幻燈片放映,以便在調用UI命令以模擬單擊CONNECT按鈕后按兩次ENTER鍵,然后單擊“ 開始演示”按鈕(DoEvents不能用作出現在模態窗口中的PowerPoint窗口,並且執行永遠不會返回到VBA)。 在連接和准備開始演示之間需要一些准備時間,對於我簡單的一張幻燈片來說 , 這只需要不到10秒,但是您可能需要根據您的內容在TimerProc過程中更改常量ENTER2 。 顯然,這是一個命中注定的事情(由於使用了SendKeys和未知的時間),因此我仍在尋找更好的機制。 您還需要確定如何共享與會者url,在本示例中,該URL只是作為Debug.Print語句輸出。 只需運行StartBroadcast過程。
' ======================================================
' =========== PowerPoint VBA Standard Module ===========
' ======================================================
' Purpose : Starts a "Present Online" broadcast session.
' Prerequisites : Access to Present Online service.
' Platform : Tested with PowerPoint 2016 (PC) only.
' Author : Jamie Garroch of YOUpresent Ltd. 24JAN2017
' http:\\youpresent.co.uk
' References : None
' ======================================================
Option Explicit
#If VBA7 Then
Public TimerID As LongPtr
Public TimerCycles As LongPtr
#Else
Public TimerID As Long
Public TimerCycles As Long
#End If
#If VBA7 Then
Private Declare PtrSafe Function SetTimer Lib "user32" _
(ByVal hwnd As LongPtr, _
ByVal nIDEvent As LongPtr, _
ByVal uElapse As LongPtr, _
ByVal lpTimerFunc As LongPtr) As LongPtr
Private Declare PtrSafe Function KillTimer Lib "user32" _
(ByVal hwnd As LongPtr, _
ByVal nIDEvent As LongPtr) As LongPtr
#Else
Private Declare Function SetTimer Lib "user32" _
(ByVal hwnd As Long, _
ByVal nIDEvent As Long, _
ByVal uElapse As Long, _
ByVal lpTimerFunc As Long) As Long
Private Declare Function KillTimer Lib "user32" _
(ByVal hwnd As Long, _
ByVal nIDEvent As Long) As Long
#End If
' Run this procedure to start the broadcast session
Sub StartBroadcast()
ActivePresentation.Windows(1).Activate
CommandBars.ExecuteMso "BroadcastSlideShow"
StartTimer
End Sub
Public Function StartTimer()
TimerID = SetTimer(0, 0, 1000, AddressOf TimerProc)
If TimerID = 0 Then Debug.Print "Timer not created.": Exit Function
Debug.Print "Timer " & TimerID & " started at : " & Now
End Function
Private Sub TimerProc(ByVal hwnd As Long, _
ByVal uMsg As Long, _
ByVal idEvent As Long, _
ByVal dwTime As Long)
TimerCycles = TimerCycles + 1
Debug.Print "Timer " & TimerID & " running : " & TimerCycles
' Number of seconds to wait before pressing ENTER the first time
' to simulate pressing the "CONNECT" button
Const ENTER1 = 1
' Number of seconds to wait before pressing ENTER the first time
' to simulate pressing the "START PRESENTATION" button
Const ENTER2 = 10
' Clicks the "CONNECT" button after ENTER1 seconds
If TimerCycles = ENTER1 Then SendKeys "{enter}"
' Clicks the "START PRESENTATION" button after ENTER2 seconds
If TimerCycles = ENTER2 Then SendKeys "{enter}"
' Output the Attendee URL for sharing and kill the timer
If TimerCycles > ENTER2 Then
Debug.Print ActivePresentation.Broadcast.AttendeeUrl
StopTimer
End If
End Sub
Public Function StopTimer()
#If VBA7 Then
Dim tmpTimerID As LongPtr
#Else
Dim tmpTimerID As Long
#End If
tmpTimerID = TimerID
TimerID = KillTimer(0, TimerID)
If TimerID = 0 Then
Debug.Print "Couldn't kill the timer"
Else
Debug.Print "Timer " & tmpTimerID & " stopped at : " & Now & " with " & TimerCycles & " cycles"
End If
TimerCycles = 0
TimerID = 0
End Function
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.