[英]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.