0

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).

I've tried using this code below to start broadcasting, but keep getting a run time error: "Client: Loading the request into SoapReader failed.."

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

How does broadcast.start() work?

Hamish
  • 1
  • 1
  • The msdn [Presentation.Broadcast](https://msdn.microsoft.com/en-us/library/office/ff744901(v=office.14).aspx) property doesn't have much documentation, but when I try your code, I got a login Prompt. If you don't have it, I guess the stored credentials are out of date and hence you get that error. Basically you are feeding that url whatever your presentation is showing. You should also add `.Broadcast.End` when you are done. – PatricK Jan 24 '17 at 04:00

1 Answers1

0

This will replicate the UI programmatically but I guess you don't want to do this as it requires user interaction:

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:

Broadcast Methods & Properties on MSDN Note that there is a smaller subset for 2010 in the Other Versions link.

Microsoft Community Discussion on Broadcast via 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:

?ActivePresentation.Broadcast.PresenterServiceUrl

It returned a localised domain with an asmx file reference:

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

But using that with the .Start method still returned the same error. I'm wondering if some preparation needs to be done (as seen when using the UI) such as saving to a OneDrive location.

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). 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. Obviously this is a bit hit and miss (because of SendKeys use and unknown times) so I'm still looking for a better mechanism. You'll also need to decide how to share the attendee url which is just output as a Debug.Print statement in this example. Just run the StartBroadcast procedure.

' ======================================================
' =========== 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
Jamie Garroch - MVP
  • 2,839
  • 2
  • 16
  • 24
  • Hi Jamie, thanks very much for your answer above. It works well. I've come to realise that the url it presents to will change every time this is run, where as I will need a static address. – Hamish Jan 25 '17 at 00:11
  • My overall project is getting some dynamic data, importing it into Excel, and then turning it into a chart (every 5 mins). I wanted then to be able to broadcast / stream it live online. Powerpoint can link to Excel to get the chart, but can't update without ending the broadcast. If every time I have a new url, I won't be able to stream it to the same spot for the end user. – Hamish Jan 25 '17 at 00:16
  • Yes, broadcast is session-based so the session ID and hence attendee URL is unique for each broadcast session. You could try the DataPoint addin to dynamically update your content during the slide show. I've not used it for many years but was impressed with the company's products (I have no relationship with them). https://www.presentationpoint.com/software/datapoint/ – Jamie Garroch - MVP Jan 25 '17 at 07:58