简体   繁体   English

Powerpoint 2010-broadcast.start()

[英]Powerpoint 2010 - broadcast.start()

I'm wanting to create a Powerpoint slide that automatically updates from a source every 5 mins then starts a broadcast service to a website (& keeps looping to refresh the content). 我想创建一个Powerpoint幻灯片,该幻灯片每5分钟从源头自动更新一次,然后启动向网站的广播服务(&不断循环以刷新内容)。

I've tried using this code below to start broadcasting, but keep getting a run time error: "Client: Loading the request into SoapReader failed.." 我尝试使用下面的代码开始广播,但始终出现运行时错误:“客户端:将请求加载到SoapReader中失败。”

Sub ShowIt()
    Application.ActivePresentation.SlideShowSettings.Run
    Application.ActivePresentation.Broadcast.Start ("https://bn1-broadcast.officeapps.live.com/")
    DoEvents
    End Sub

How does broadcast.start() work? broadcast.start()如何工作?

This will replicate the UI programmatically but I guess you don't want to do this as it requires user interaction: 这将以编程方式复制UI,但我想您不想这样做,因为它需要用户交互:

Application.CommandBars.ExecuteMso "BroadcastSlideShow"

Two semi-useful links which might help although as PatricK points out, documentation [with working examples] seem to be impossible to find: 两个半有用的链接可能会有所帮助,尽管正如PatricK所指出的那样,[带有有效示例]的文档似乎找不到:

Broadcast Methods & Properties on MSDN Note that there is a smaller subset for 2010 in the Other Versions link. MSDN上的广播方法和属性请注意,“其他版本”链接中2010年的子集较小。

Microsoft Community Discussion on Broadcast via VBA Microsoft社区关于通过VBA广播的讨论

I didn't even get as far as you and I get the error "Method 'Start' of object 'Broadcast' failed". 我什至没有得到你的帮助,并且得到了错误“对象“广播”的方法“开始”失败”。 I then started the broadcast session via the PowerPoint 2016 UI (Slide Show / Present Online) and then used the following in the Immediate window to return the service URL: 然后,我通过PowerPoint 2016 UI(幻灯片显示/在线演示)开始了广播会话,然后在“即时”窗口中使用以下命令返回服务URL:

?ActivePresentation.Broadcast.PresenterServiceUrl

It returned a localised domain with an asmx file reference: 它返回了带有asmx文件引用的本地化域:

https://ie1-broadcast.officeapps.live.com/m/present_2_0.asmx

But using that with the .Start method still returned the same error. 但是,将其与.Start方法一起使用仍会返回相同的错误。 I'm wondering if some preparation needs to be done (as seen when using the UI) such as saving to a OneDrive location. 我想知道是否需要做一些准备工作(如使用UI时所见),例如保存到OneDrive位置。

Using PowerPoint 2016 (PC), I managed to connect to the Present Online service and start the slide show using WinAPIs for VBA thread independent timers so that the ENTER key is pressed twice after invoking the UI command to simulate the clicking of the CONNECT button and then the START PRESENTATION button (DoEvents can't be used as the PowerPoint windows that appear are modal and execution never returns to VBA). 使用PowerPoint 2016(PC),我设法连接到Present Online服务,并使用WinAPIs for VBA线程独立计时器启动幻灯片放映,以便在调用UI命令以模拟单击CONNECT按钮后按两次ENTER键,然后单击“ 开始演示”按钮(DoEvents不能用作出现在模态窗口中的PowerPoint窗口,并且执行永远不会返回到VBA)。 There is some preparation time between connecting and being ready to start the presentation which for my simple one slide deck was just under 10 seconds but you might need to change the constant ENTER2 in the TimerProc procedure based on your content. 在连接和准备开始演示之间需要一些准备时间,对于我简单的一张幻灯片来说这只需要不到10秒,但是您可能需要根据您的内容在TimerProc过程中更改常量ENTER2 Obviously this is a bit hit and miss (because of SendKeys use and unknown times) so I'm still looking for a better mechanism. 显然,这是一个命中注定的事情(由于使用了SendKeys和未知的时间),因此我仍在寻找更好的机制。 You'll also need to decide how to share the attendee url which is just output as a Debug.Print statement in this example. 您还需要确定如何共享与会者url,在本示例中,该URL只是作为Debug.Print语句输出。 Just run the StartBroadcast procedure. 只需运行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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM