Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- On Error Resume Next
- ' AutoPowerPoint VBScript
- ' Based on several scripts:
- ' Mostly Sog's post on ArsTechnica: https://tinyurl.com/y8x5shr2
- ' ScriptingGuy1, on TechNet: https://tinyurl.com/yd6zw7zp
- ' MJSN's Thread on ExpertsExchange: https://tinyurl.com/ycrjojb7
- ' StephnMoll's post on Idera: https://tinyurl.com/y7eacxpj
- ' Amrita M's PPT to Slideshow Post: https://tinyurl.com/yb3zm98g
- ' Reece's post on SO: https://tinyurl.com/y6uq63qm
- ' Powerpoint CMD Options: https://tinyurl.com/ya6lfs25
- ' CompPerf Post from XP-Era: https://tinyurl.com/54pkgn
- ' The Scripting Guys' 3rd Post: https://tinyurl.com/y6vdvqft
- ' The Scripting Guys' NewFiles Post: https://tinyurl.com/mosqnhj
- ' Tao's SO Post: https://tinyurl.com/yalxkdpu
- ' Garry's AHK Post: https://tinyurl.com/ydfolmg8
- '
- ' -
- ' Date: 2018-03-02
- ' Office Ver: 2016 Home & Business (Standalone Vol)
- ' OS: Windows 7 Home Premium x64
- ' -
- ' DevEnv: Windows 7 Professional x64
- ' -
- '
- ' TODO: Restart Presentation w/out reboot
- ' TODO: Add support for other file extensions
- ' TODO:
- '
- ' ---------------------------------------------------------
- ' Variable Definitions
- ' ---------------------------------------------------------
- ' Define the filename of your PPT/PPTX file
- objFileName = "SalesLeaderBoard.ppt"
- ' Define Folder to watch for updated file(s)
- ' Note, M:\ References \Marketing
- objUpdatePath = "M:\ConfSlideShow\"
- ' Define path to latest PPT file
- objExecutePath = "C:\PPTKioskFiles\"
- ' Define path to last-known-good file
- ' Note, M:\ References \Marketing
- objLGKPath = "M:\ConfSlideShow\LKGFile\"
- ' Define if a file runs with preset or user-defined timings
- ' 0 == preset (2s per slide)
- ' 1 == user-defined
- objSlideShowSetting = 0
- ' Define view time per slide, in seconds
- objSlideShowSlideTime = 4
- ' Build ful paths/names of update and exec files
- objFileUpdate = (objUpdatePath & objFileName)
- objFileExecute = (objExecutePath & objFileName)
- objLKGFile = (objLKGPath & objFileName)
- ' Set configuration for the slideshow
- If objSlideShowSetting = 0 Then
- Const ppAdvanceOnTime = 2
- Else
- ppAdvanceTime = objSlideShowSlideTime
- End If
- ' Set Slide Show to display in Kiosk Mode
- Const ppShowTypeKiosk = 3
- ' Enforce the SlideShow to show all slides
- Const ppSlideShowDone = 5
- ' Define FuncObjs here
- Set objFSO = CreateObject("Scripting.FileSystemObject")
- Set objPPT = createObject("PowerPoint.Application")
- Set objPresentation = objPPT.Presentations.Open(objFileExecute, True, True)
- Set objSlideShow = objPresentation.SlideShowSettings.Run.View
- Set objFile = objFSO.GetFile(objFileExecute)
- ' ----------------------------------------------------------
- ' Functions
- ' ----------------------------------------------------------
- ' Initialize the project
- Function Initialize()
- ' Ensure file exists; else, display error and quit
- Set objFSO = CreateObject("Scripting.FileSystemObject")
- If objFSO.FileExists(objFileExecute) Then
- Else
- WScript.Echo "Error: Your presentation does not exist!"
- WScript.Echo "Please place " & objFileName & " in " & objExecutePath
- WScript.Quit
- End If
- ' Rededine FunObjs
- Set objPPT = createObject("PowerPoint.Application")
- Set objPresentation = objPPT.Presentations.Open(objFileExecute, True, True)
- Set objSlideShow = objPresentation.SlideShowSettings.Run.View
- Set objFile = objFSO.GetFile(objFileExecute)
- End Function
- Function StartPPT()
- ' Open the Presentation & make it visible
- Set objPPT = createObject("PowerPoint.Application")
- objPPT.Visible = True
- Set objPresentation = objPPT.Presentations.Open(objFileExecute, True, True)
- ' Execute the above config for the slideshow
- If objSlideShowSetting = 0 Then
- objPresentation.Slides.Range.SlideShowTransition.ppAdvanceOnTime = True
- objPresentation.SlideShowSettings.AdvanceMode = ppAdvanceOnTime
- Else
- objPresentation.Slides.Range.SlideShowTransition.AdvanceTime = ppAdvanceOnTime
- End If
- ' Enable Kiosk Mode
- objPresentation.SlideShowSettings.ShowType = ppShowTypeKiosk
- ' Define start and end slides to be presented
- objPresentation.SlideShowSettings.StartingSlide = 1
- objPresentation.SlideShowSettings.EndingSlide = objPresentation.Slides.Count
- ' Run the Slideshow
- Set objSlideShow = objPresentation.SlideShowSettings.Run.View
- End Function
- Function StopPPT()
- objPresentation.Saved = True
- objPresentation.Close
- objPPT.Quit
- End Function
- Function UpdateFile()
- ' First, though, save and close the presentation
- objPresentation.Saved = True
- objPresentation.Close
- objPPT.Quit
- ' Net, Copy ExecFile to LKGFilePath; overwrite existing if necessary
- objFSO.CopyFile objFileExecute, objLKGFile, True
- ' Delete execFile
- objFSO.DeleteFile objFileExecute
- ' Move updateFile to execFile
- Set objFile = objFSO.GetFile(objFileExecute)
- objFSO.MoveFile objFileUpdate, objFileExecute
- End Function
- ' ----------------------------------------------------------
- ' Logic / Run
- ' ----------------------------------------------------------
- ' Init environment
- Call Initialize()
- ' Start PPT with the above conf
- Call StartPPT(objPPT, objPresentation, objSlideShow)
- ' Run the PPT until sigkill || err
- Do Until objSlideShow.State = ppSlideShowDone
- ' If an update file exists, move to execute location && make a backup copy of the current file
- If objFSO.FileExists(objFileUpdate) Then
- Call UpdateFile()
- Call StopPPT()
- WScript.Sleep 7000
- Call StartPPT()
- Exit Do
- End If
- ' Exception Handler
- If err <> 0 Then
- objPresentation.Saved = True
- objPresentation.Close
- objPPT.Quit
- Exit Do
- End If
- Loop
- WScript.Quit
Add Comment
Please, Sign In to add comment