Controlling OBS using PowerPoint with VBA code in Windows
This document explains how to make PowerPoint control OBS scenes as you advance slides.
1> The first part is to activate Websockets in OBS.
Enable it, we can use the default port of 4455 and then set a password
"Nutty's Official OBS Commander - NOOBS CMDR"
This program will translate commands in a .BAT file and send them to an OBS instance.
Create a PowerPoint document, create a VBA macro and the code at the bottom of this document.
It will look like the following:
Create .BAT files on the PowerPoint computer with syntax similar to the following.
OBSCommand.exe /server=OBSipADDRESS:4455 /password="YOURpassWORD" /scene="SCENEnameEXACT Spelling"
scene= name will contain the name of the scene you want your OBS to go to when you execute this command
server=the IP of your OBS computer.
password= Password you assigned in the websockets window
Save the file as the name of what you will call it in power point as a reference.
If you want to use the word "Widescreen" to switch your camera to a scene that has a wide shot, name the file "widescreen.bat". In our system we have "choir.bat" and "closeup.bat".
Place these files in the c:\obscommand folder that is created when you install the OBS command application.
Upon creation of these files, you can double click them and you should see your OBS reflecting the changes. Once you have that working, continue to the next step.
5> In your PowerPoint Document put in the first line of the presenter notes the following:
widescreen
6> Start your presentation, then activate the macro.
7> Now in presentation mode, as you goto the slides with the name in the presenation, you should see the slides change.
PowerPoint vba script
What the code does is watch the Presentation View of your PowerPoint, and reads the first 15 characters of the first line. Then it adds a .BAT to the end of whatever word is there and tells your PowerPoint computer to run any file with that name in the folder. If matching, then it will run that code and that code will send commands to your OBS.
Sub OnSlideShowPageChange()
On Error GoTo ErrorHandler
Dim ActiveSlide As Integer
Dim ActiveSlideNotes As String
Dim FullCommand As String
Dim WAIT As Double
Dim strTextUCase As String
ActiveSlide = ActivePresentation.SlideShowWindow.View.CurrentShowPosition
ActiveSlideNotes = Left(ActivePresentation.Slides(ActiveSlide).NotesPage.Shapes.Placeholders(2).TextFrame.TextRange.Text, 11) 'get the first 11 characters of the notes file
strTextUCase = UCase(ActiveSlideNotes) 'convert all characters to uppercase. The .bat files don't care but the macro does care
ActiveSlideNotes = strTextUCase
FullCommand = Left(ActiveSlideNotes, 15) 'get the right most 15 characters xxx-yyy
Shell ("CMD.EXE /c C:\OBSCommand\" & FullCommand & ".bat") 'send a shell command based on the value found, with .BAT added to the end.
done:
AppActivate ("PowerPoint")
'IF the macro is run but the slideshow isn't, this will start the current one in presentation mode
ErrorHandler:
Dim pptApp As PowerPoint.Application
Dim pptPres As PowerPoint.Presentation
Set pptApp = PowerPoint.Application ' Use the current instance of PowerPoint
Set pptPres = pptApp.ActivePresentation ' Start the slide show from the first slide
pptPres.SlideShowSettings.StartingSlide = 1
pptPres.SlideShowSettings.EndingSlide = pptPres.Slides.Count
pptPres.SlideShowSettings.ShowWithNarration = True
pptPres.SlideShowSettings.ShowWithAnimation = True
pptPres.SlideShowSettings.Run
End Sub
No comments:
Post a Comment
Feel free to leave a comment! If you have any information that you think should be included, please do so here and I'll get it added in.