none
Script to lunch powerpoint in kiosk mode and refresh when new update available RRS feed

  • Question

  • I need help.. script that will run powerpoint presentation in a kiosk mode then once a new file (updated) becomes available program will refresh and run the latest file.

    I found one in the internet but instead of just copying the file it moved the new file and saved to the active folder.

    - this part i want to change instead of move I want to copy only and save to active folder then load the presentation.

    if objFSO.FileExists(objFileUpdate) Then

        'Stop the presentation
          objPresentation.Saved = True
          objPresentation.Close
          objPPT.Quit

          'Delete the execute file if it exists.  MoveFile method does not allow overwriting files.
          objFSO.DeleteFile objFileExecute

          'Move the update file to the execute location   
          Set objFile = objFSO.GetFile(objFileUpdate)
          objFSO.CopyFile objFileUpdate , objFileExecute
          Exit Do
      End If

    loop

    • Moved by Bill_Stewart Friday, November 18, 2016 3:19 PM Move to more appropriate forum
    Friday, November 18, 2016 9:02 AM

All replies

  • You will need to create a macro in the presentation that looks for the new file and reloads with the new file.  It is the easiest way to do this.

    Run the macro on each slide change or on the last slide.


    \_(ツ)_/

    Friday, November 18, 2016 9:35 AM
  • cool thats great any idea about the macro I need to add in?
    Friday, November 18, 2016 9:58 AM
  • You can easily write one.

    Post issue in PowerPoint forum to learn how to do this.  The question  has been asked before a few times in the last couple of years so try searching too.  It is a common request.


    \_(ツ)_/

    Friday, November 18, 2016 10:03 AM
  • Thanks JRV i still cant find.. :(  

    can anyone have the link or other suggestion?

    Saturday, November 19, 2016 5:47 AM
  • I haven't done any PowerPoint VBA in a long time.  I would think you would need to use a separate program to look for file updates and restart PowerPoint with the new file.  I do this with Word when I detect a new addin.  For example you could create an Excel addin that runs daily or hourly using Task Scheduler.  If a new file is detected Excel stops PowerPoint, transfers the file and restarts it PowerPoint with the new file.  You can probably do this with a bat file, Powershell or C# program so you don't need Excel.

    In C# there is a capability to detect when a file changes so you don't need a timer.

    • Edited by mogulman52 Saturday, November 19, 2016 1:35 PM
    Saturday, November 19, 2016 1:14 PM
  • Hint:  A VBA project can close the current PP show and open a new one or copy a file then open it.  It only takes a few lines of code.  It can all be done in the SShowBegin event of PP.


    \_(ツ)_/

    Saturday, November 19, 2016 1:40 PM
  • Simple example:

    Private Sub App_SlideShowEnd(ByVal Pres As Presentation)
    
        FileCopy "\\server\share\presentation.ppt", "c:\show"
        PowerPoint.Presentations.Open ("c:\show\presentation.ppt")
        With ActivePresentation.SlideShowSettings
            .ShowType = ppShowSpeaker
            .Run.View.AcceleratorsEnabled = False
        End With
        
    End Sub
    


    \_(ツ)_/

    Saturday, November 19, 2016 1:59 PM
  • Thanks Mogulman, yes thats exactly what i am looking for a bat file or script or any macro to add or anything that will check once new file becomes available it will push that to active presentation and load or will kill the current active presentation and replaced with the new file.

    To be honest I am not that good also in scripting and running out of ideas already how to get this workin.

    I hope someone can guide me thru on this really very important project i need to work on.

    Anyways thanks for your reply appreciate it.

    Saturday, November 19, 2016 4:24 PM
  • Thanks JRV sorry man im not that good in this scripting really appreciate your kind reply but can you help me how exactly I need to get this working?

    appreciate if you can guide me along.


    Saturday, November 19, 2016 4:26 PM
  • Sorry.  I cannot do this for you.  I suggest you start by learning a bit abut coding with PPT.

    \_(ツ)_/

    Saturday, November 19, 2016 5:36 PM
  • No worries thanks.

    Sunday, November 20, 2016 11:52 AM
  • anyone got idea how to do this?

    Sunday, November 20, 2016 1:28 PM
  • I took a quick look at PP.  You can use VBA to start a presentation and loop through it.  I saw no way to interrupt the loop other than clicking the screen.  Also there appears to be no way to show it once and show it again without clicking to exit the first time.  Therefore, you need a program to start PP which automatically starts the presentation to loop (ActivePresentation.SlideShowSettings.LoopUntilStopped = True).  It will have to get the process ID for PP.  This program will have a timer to poll for a new file.  If it finds one it will kill PP using the process ID, copy the file and restart PP.  You can probably do it in Excel using Win32 commands or in a separate instance of PP.  I would use C#.  It can probably be done in C# with 25 lines of code.

    Sunday, November 20, 2016 6:22 PM
  • I took a quick look at PP.  You can use VBA to start a presentation and loop through it.  I saw no way to interrupt the loop other than clicking the screen.  Also there appears to be no way to show it once and show it again without clicking to exit the first time.  Therefore, you need a program to start PP which automatically starts the presentation to loop (ActivePresentation.SlideShowSettings.LoopUntilStopped = True).  It will have to get the process ID for PP.  This program will have a timer to poll for a new file.  If it finds one it will kill PP using the process ID, copy the file and restart PP.  You can probably do it in Excel using Win32 commands or in a separate instance of PP.  I would use C#.  It can probably be done in C# with 25 lines of code.

    It we start a PP slideshow as posted above then it will generate all slide change events.  The "Begin" and End" events can execute VBA that can close and open a new file as posted above.  This is don in many PPT shows.

    Look at the VBA reference for PP to see what events are available and how to code them.


    \_(ツ)_/

    Sunday, November 20, 2016 7:02 PM
  • Thanks Mogulman appreciate your input.
    Monday, November 21, 2016 3:18 AM
  • I did look at events.  I found no way to interrupt a running presentation using VBA and events.  I tried doing a SendKeys to send an Escape but it didn't work.  If you know of a way to stop a running presentation using VBA let me know.  So far, I stand by earlier comment.
    Monday, November 21, 2016 3:19 AM
  • I did look at events.  I found no way to interrupt a running presentation using VBA and events.  I tried doing a SendKeys to send an Escape but it didn't work.  If you know of a way to stop a running presentation using VBA let me know.  So far, I stand by earlier comment.

    There are many ways to do this.  You clearly do not understand how PP works.  We create an Add-In presentation with a declaration of an App object and define the events.  On and slide event we can execute code.

    There are dozens of events generated during the life cycle of a presentation.  We can catch any of these events and execute VBA code.  This is standard for PPT.


    \_(ツ)_/

    Monday, November 21, 2016 4:21 AM
  • If you just want to do this as a simple scheduled task then you can do it with this script:

    $newpptfile = '\\server\share\FluView53.pptm'
    $pptfile = 'd:\test3\FluView53.pptm'
    $newfile = Get-Item '\\server\share\FluView53.pptm'
    $currentFile = Get-Item $pptfile
    if($currentFile.LasWriteTime -lt $newfile.LastWriteTime){
    	$pp = New-Object -ComObject PowerPoint.Application
    	if($pptp = $pp.Presentations[$pptfile]){
    		$pp.SlideShowWindows[1].Presentation.Close()
    		$newfile | Copy-Item -Destination $pptfile 
    		$pptp = $pp.Presentations.Open($pptfile)
    		$show = $pptp.SlideShowSettings.Run()
    	}
    }
    


    \_(ツ)_/

    Monday, November 21, 2016 4:22 AM
  • That is similar to the code I have.  Once it is running how do you stop it with code.  I have a new slide event and count like 10 slides then try to stop loop (LoopUntilStop = True).  I found no way to stop a running presentation and your code doesn't provide any solution.  If you could provide the code to replace SendKeys "{ESC}" that would solve it.

    Public Sub App_SlideShowNextSlide(ByVal Wn As SlideShowWindow)
      If cnt > 10 Then
        SendKeys "{ESC}", True  ' Doesn't work
        cnt = 0
      End If
      cnt = cnt + 1
    End Sub

    Monday, November 21, 2016 1:39 PM
  • That is similar to the code I have.  Once it is running how do you stop it with code.  I have a new slide event and count like 10 slides then try to stop loop (LoopUntilStop = True).  I found no way to stop a running presentation and your code doesn't provide any solution.  If you could provide the code to replace SendKeys "{ESC}" that would solve it.

    Public Sub App_SlideShowNextSlide(ByVal Wn As SlideShowWindow)
      If cnt > 10 Then
        SendKeys "{ESC}", True  ' Doesn't work
        cnt = 0
      End If
      cnt = cnt + 1
    End Sub

    What code are you referring to?  If you have enabled events then you can just use the SlideShowSettings object to control the show.

    You cannot send keys to the screen.

    If you have not create the add-in and created the "Application object in the startup or load of the add-in then no events can be handled.

    The PowerShell code manages the show once on each execution under the task scheduler and doesn't require events or an add-in.

    In your code you have not defined "cnt" anywhere.  It will always be zero.


    \_(ツ)_/


    • Edited by jrv Monday, November 21, 2016 2:05 PM
    Monday, November 21, 2016 2:04 PM
  • I didn't include all the class code just the event code.  Anyway after spending 30 minutes with the object browser I solved the problem. Here is all the class code (MyEventsClass) to interrupt and close presentation. 

    Public WithEvents App As Application
    Public cnt As Long
    
    Public Sub App_SlideShowNextSlide(ByVal pres As SlideShowWindow)
      If cnt > 10 Then
        pres.Presentation.Close
        cnt = 0
      End If
      cnt = cnt + 1
    End Sub
    

    It should be easy to solve now.

    Here is module code.

    Dim ppCls As New MyEventsClass
    
    Sub RunShow()
    
        PowerPoint.Presentations.Open ("c:\temp\test.pptx")
        For Each s In ActivePresentation.Slides
          s.SlideShowTransition.AdvanceOnTime = True
          s.SlideShowTransition.AdvanceTime = 5
        Next s
    
        ActivePresentation.SlideShowSettings.RangeType = ppShowSlideRange
        ActivePresentation.SlideShowSettings.StartingSlide = 1
        ActivePresentation.SlideShowSettings.EndingSlide = 3
        ActivePresentation.SlideShowSettings.AdvanceMode = ppSlideShowUseSlideTimings
        ActivePresentation.SlideShowSettings.LoopUntilStopped = True
        ActivePresentation.SlideShowSettings.Run
    End Sub
    
    Sub Test()
        Set ppCls.App = Application
        Call RunShow
    End Sub
    

    Monday, November 21, 2016 4:25 PM
  • I got it working.  In this version every 10 slides it checks for a new file.  If it finds one it stops the presentation, copies the new file to the current file, deletes the new file and restarts show.

    Class module (MyEventsClass)

    Public WithEvents App As Application
    Private cnt As Long
    Private fso As New FileSystemObject  ' Reference Microsoft Scripting Runtime
    
    Public Sub App_SlideShowNextSlide(ByVal pres As SlideShowWindow)
      If cnt > 10 Then
        If fso.FileExists("C:\temp\newPres.pptx") Then
          pres.Presentation.Close
          fso.DeleteFile ("C:\temp\curPres.pptx")
          fso.CopyFile "C:\temp\newPres.pptx", "C:\temp\curPres.pptx", False
          fso.DeleteFile ("C:\temp\newPres.pptx")
          Call RunShow
        End If
        cnt = 0
      End If
      cnt = cnt + 1
    End Sub

    Module Code

    Dim ppCls As New MyEventsClass
    
    Sub RunShow()
    
        PowerPoint.Presentations.Open ("c:\temp\curPres.pptx")
        For Each s In ActivePresentation.Slides
          s.SlideShowTransition.AdvanceOnTime = True
          s.SlideShowTransition.AdvanceTime = 5
        Next s
    
        ActivePresentation.SlideShowSettings.RangeType = ppShowSlideRange
        ActivePresentation.SlideShowSettings.StartingSlide = 1
        ActivePresentation.SlideShowSettings.EndingSlide = 3
        ActivePresentation.SlideShowSettings.AdvanceMode = ppSlideShowUseSlideTimings
        ActivePresentation.SlideShowSettings.LoopUntilStopped = True
        ActivePresentation.SlideShowSettings.Run
    End Sub
    
    Sub Test()
        Set ppCls.App = Application
        Call RunShow
    End Sub
    

    You probably want to add error checking.  You also want to check that the new file is a few minutes old to insure it is not being written at the same time your checking.

    Monday, November 21, 2016 5:21 PM
  • Awesome thats cool Big thanks Mogulman.. :)

    im gonna try this one 

    Wednesday, November 23, 2016 3:02 AM
  • Hi Mogulman can you please drop me email macariola@hotmail.com need to ask you question.. thanks 
    Wednesday, November 23, 2016 3:27 AM