|
-
Oct 9th, 2012, 10:25 AM
#1
Thread Starter
New Member
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
-
Oct 9th, 2012, 01:52 PM
#2
Re: VB Script Do Loop errors
you have a giant outer loop... you cannot declare subs within loops...
-tg
-
Oct 9th, 2012, 02:26 PM
#3
Thread Starter
New Member
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
-
Oct 9th, 2012, 03:40 PM
#4
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
-
Oct 10th, 2012, 05:20 AM
#5
Thread Starter
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|