VBS For 2002 versus 2003

  • Thread starter Thread starter BoomerM3
  • Start date Start date
B

BoomerM3

The following script (adaped from a MS example runs fine in PowerPoint
2002 but fails in 2003 (error noted in code comment). Two questions:
1. Can anyone help me get this to work in 2003?
2. Is it possible to modify this script so it will work in all versions
(or most versions)?

Thanks
peter

Const ppAdvanceOnTime = 2
Const ppShowTypeKiosk = 3
Const ppSlideShowDone = 5

Set objPPT = CreateObject("PowerPoint.Application")
objPPT.Visible = True

Set objPresentation = objPPT.Presentations.Open("d:\down\Nothing.pps")

objPresentation.Slides.Range.SlideShowTransition.AdvanceTime = 2
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

'*** The "State" object not recognized in 2003 and PowerPoint
'*** wants to save changes in 2003 - not 2002
Do Until objSlideShow.State = ppSlideShowDone
Loop

'added to quit PPT
objPresentation.Close
objPPT.Quit
 
Why not change :
Do Until objSlideShow.State = ppSlideShowDone
Loop

While SlideShowWindows.Count > 0
do events
loop

Haven't tested it, but it should do the trick for you.


--
Bill Dilworth
A proud member of the Microsoft PPT MVP Team
Users helping fellow users.
http://billdilworth.mvps.org
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
yahoo2@ Please read the PowerPoint FAQ pages.
yahoo. They answer most of our questions.
com www.pptfaq.com
..
 
SlideShowWindows.Count results in a runtime error - "Object Required".

peter
 
so ....

add 'objPresentation.' in front of the SlideShowWindows.Count

you may also want to toss a DoEvents into the checking loop.

Bill
 
Now errors with:
"Object doesn't support this property or method:
objPresentation.SlideshowWindows"

BTW, neither Do....Loop nor DoEvents are allowable syntax in VBS.


peter
 
BoomerM3 said:
The following script (adaped from a MS example runs fine in PowerPoint
2002 but fails in 2003 (error noted in code comment). Two questions:
1. Can anyone help me get this to work in 2003?
2. Is it possible to modify this script so it will work in all versions
(or most versions)?

Thanks
peter

Const ppAdvanceOnTime = 2
Const ppShowTypeKiosk = 3
Const ppSlideShowDone = 5

Set objPPT = CreateObject("PowerPoint.Application")
objPPT.Visible = True

Set objPresentation = objPPT.Presentations.Open("d:\down\Nothing.pps")

objPresentation.Slides.Range.SlideShowTransition.AdvanceTime = 2
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

'*** The "State" object not recognized in 2003 and PowerPoint
'*** wants to save changes in 2003 - not 2002

I expect it wants to save because you've changed the slide show settings.
Try setting the presentation's .Saved property to TRUE before you quit.

Then try this:

ActivePresentation.SlideShowSettings.Run
With SlideShowWindows(1)

On Error Resume Next

Do
DoEvents
DoEvents
DoEvents
Loop Until .State = ppSlideShowDone

End With
MsgBox "DONE"

Kind of ugly, but it works. Problem is not that 2003 doesn't recognize .State
(it does here) but that the loop errors when the show quits because it's trying
to test the state of something that no longer exists.
 
You correctly provided the VBS in the subject line and I read VBA, my
apologies. I tend not to write in script, so will bow out at this point in
favor of someone that does write in VBS.

the microsoft.public.scripting.vbscript newgroup may also be able to lend a
hand.


--
Bill Dilworth
A proud member of the Microsoft PPT MVP Team
Users helping fellow users.
http://billdilworth.mvps.org
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
yahoo2@ Please read the PowerPoint FAQ pages.
yahoo. They answer most of our questions.
com www.pptfaq.com
..
 
Steve,

I still get the error: State = ppSlideShowDone doesn't support this
property. While VBS doesn't support DoEvents, I have put large delays
in the loop. At some point, the error pops up.

Is there another way to check for the completion of a show? Thanks for
your help!!

peter
 
Steve,

I still get the error: State = ppSlideShowDone doesn't support this
property. While VBS doesn't support DoEvents, I have put large delays
in the loop. At some point, the error pops up.

I'm afraid I don't use VBS, so I can't offer much else in the way of help. :-(
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top