Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vba Powerpoint 2010-broadcast.start()_Vba_Powerpoint_Powerpoint 2010 - Fatal编程技术网

Vba Powerpoint 2010-broadcast.start()

Vba Powerpoint 2010-broadcast.start(),vba,powerpoint,powerpoint-2010,Vba,Powerpoint,Powerpoint 2010,我想创建一个Powerpoint幻灯片,每5分钟自动更新一次,然后启动一个网站的广播服务(不断循环刷新内容) 我已尝试使用下面的代码开始广播,但不断出现运行时错误: “客户端:将请求加载到SoapReader失败..” broadcast.start()如何工作?这将以编程方式复制UI,但我猜您不想这样做,因为它需要用户交互: Application.CommandBars.ExecuteMso "BroadcastSlideShow" 两个半有用的链接可能会有所帮助,尽管正如PatricK指

我想创建一个Powerpoint幻灯片,每5分钟自动更新一次,然后启动一个网站的广播服务(不断循环刷新内容)

我已尝试使用下面的代码开始广播,但不断出现运行时错误: “客户端:将请求加载到SoapReader失败..”


broadcast.start()如何工作?

这将以编程方式复制UI,但我猜您不想这样做,因为它需要用户交互:

Application.CommandBars.ExecuteMso "BroadcastSlideShow"
两个半有用的链接可能会有所帮助,尽管正如PatricK指出的,文档[带有工作示例]似乎不可能找到:

请注意,在“其他版本”链接中有一个较小的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),我成功地连接到当前的在线服务,并使用WinAPI for VBA线程无关计时器启动幻灯片放映,以便在调用UI命令模拟单击“连接”按钮和“启动演示文稿”按钮后,按两次ENTER键(DoEvents不能用作显示为模式且执行永远不会返回VBA的PowerPoint窗口)。在连接和准备开始演示之间有一段准备时间,对于我简单的单幻灯片演示,这段时间不到10秒,但您可能需要根据您的内容更改TimerProc过程中的常量enter 2。显然这是一个有点碰运气的过程(由于SendKeys的使用和未知时间),因此我仍在寻找更好的机制。您还需要决定如何共享作为调试输出的与会者url。在本例中,打印语句。只需运行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

msdn属性没有太多文档,但是当我尝试你的代码时,我得到了一个登录提示。如果你没有,我猜存储的凭据已过期,因此你会出现错误。基本上,无论演示文稿显示什么,你都会输入该url。完成后,你还应该添加
.Broadcast.End
。嗨,Jamie,非常感谢您在上面的回答。它工作得很好。我逐渐意识到,每次运行它时,它显示给的url都会发生变化,因为我需要一个静态地址。我的整个项目是获取一些动态数据,将其导入Excel,然后将其转换为图表(每5分钟一次)。然后,我希望能够在线直播/流式播放。Powerpoint可以链接到Excel以获取图表,但不能在不结束广播的情况下进行更新。如果每次我有一个新url,我将无法将其流式播放到最终用户的同一地点。是的,广播是基于会话的,因此会话ID和与会者url对于每个bro都是唯一的adcast会话。您可以尝试使用DataPoint加载项在幻灯片放映期间动态更新您的内容。我已经多年没有使用它了,但对公司的产品印象深刻(我与他们没有任何关系)。
' ======================================================
' =========== 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