Results 1 to 5 of 5

Thread: VB Script Do Loop errors

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2012
    Posts
    3

    VB Script Do Loop errors

    Hi All,

    I've got the following code that run's one PowerPoint presentation, closes it down, searches through a specified folder structure for another presentation - runs it if there is one there and does nothing if there isn't one:

    Code:
    Do
    
    On Error Resume Next
    
    Const ppAdvanceOnTime = 2
    Const ppShowTypeKiosk = 3
    Const ppSlideShowDone = 5
    
    Set objPPT = CreateObject("PowerPoint.Application")
    objPPT.Visible = True
    
    Set objPresentation = objPPT.Presentations.Open("S:\common\AV Screens\JonTest.ppt")
    
    objPresentation.Slides.Range.SlideShowTransition.AdvanceOnTime = TRUE
    objPresentation.SlideShowSettings.AdvanceMode = ppAdvanceOnTime 
    objPresentation.SlideShowSettings.ShowType = ppShowTypeKiosk
    objPresentation.SlideShowSettings.StartingSlide = 1
    objPresentation.SlideShowSettings.EndingSlide = objPresentation.Slides.Count
    
    Set objSlideShow = objPresentation.SlideShowSettings.Run.View
    
    Do Until objSlideShow.State = ppSlideShowDone
        If Err <> 0 Then
            Exit Do
        End If
          
    Loop
    
    objPresentation.Saved = True
    objPresentation.Close
    set objPresentation = Nothing
    
    
     Dim objFSO, objFolder, sPath 
    Set objFSO = CreateObject("Scripting.FileSystemObject")  
    sPath = "S:\common\AV Screens\BIA" 
    Set objFolder = objFSO.GetFolder(sPath) 
    getPPTFiles objFolder 
    getSubFolder objFolder 
       
     Sub getSubFolder(pCurrentDir) 
     For Each bItem In pCurrentDir.SubFolders 
          getPPTFiles bItem 
     Next 
    End Sub 
       
     Sub getPPTFiles(myFolder) 
     For Each PPTFile in myFolder.Files 
      myFile = myFolder + "\" + PPTFile.Name 
         If LCase(objFSO.GetExtensionName(myFile)) = "ppt" Then 
            'Wscript.Echo "PPT_Path - " & myFile 
            RunPPTShow myFile
         End If 
     Next 
    End Sub 
       
     Sub RunPPTShow(PPT_Path) 
      On Error Resume Next
     
     Set objPPT = CreateObject("PowerPoint.Application") 
     objPPT.Visible = True 
     
     Set objPresentation = objPPT.Presentations.Open(PPT_Path) 
     
     objPresentation.Slides.Range.SlideShowTransition.AdvanceOnTime = TRUE 
     objPresentation.SlideShowSettings.AdvanceMode = ppAdvanceOnTime  
     objPresentation.SlideShowSettings.ShowType = ppShowTypeKiosk 
     objPresentation.SlideShowSettings.StartingSlide = 1 
     objPresentation.SlideShowSettings.EndingSlide = objPresentation.Slides.Count 
       
     Set objPPT = objPresentation.SlideShowSettings.Run.View 
     Do Until objPPT.State = ppSlideShowDone 
      If Err <> 0 Then 
       Exit Do 
      End If       
     Loop 
     
    objPresentation.Saved = True
    objPresentation.Close
    set objPresentation = Nothing
    
    	End Sub
    
    Loop
    Now, I've included an infinity loop so this process should continue all day. However, when i try and run it with the loop in it the current place, I get a syntax error on the following line:

    Code:
     Sub getSubFolder(pCurrentDir)
    Does anyone have any ideas about how I can get this to loop indefinitely?

    Thanks very much!
    Jon

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: VB Script Do Loop errors

    you have a giant outer loop... you cannot declare subs within loops...

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2012
    Posts
    3

    Re: VB Script Do Loop errors

    Damn - hoped it would be that simple!!

    Is there any way to do this? To recap, I need this to run a specified powerpoint presentation, seach a folder to see if there is a powerpoint spreadsheet and run it, then look back to the beginning and start over.

    Thanks

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: VB Script Do Loop errors

    yeah... you jsut need to move the end of your loop to jsut above the definition of the first sub... that's all it is... a simple misplaced end of a loop.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5

    Thread Starter
    New Member
    Join Date
    Oct 2012
    Posts
    3

    Re: VB Script Do Loop errors

    You, sir, are a gentleman and a scholar!! Simple things!! Thanks very much, now works perfectly

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width