Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Need help with powerpoint automation...

Reply
 
Old 10-22-2008   #1 (permalink)
reinhold.fiedler


 
 

Need help with powerpoint automation...

the script found at msdn scripting guys does end with an error if the
option "END WITH BLACK SLIDE" is "NOT" selected in the poperpoint
option menue. can anybody help me?
tested with pp2003 & pp2007
code http://www.microsoft.com/technet/scr.../ofppvb01.mspx

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

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

Set objPresentation = objPPT.Presentations.Open("C:\test.ppt")

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

Do Until objSlideShow.State = ppSlideShowDone
If err Then
wscript.echo "Error number " & err & " : " & Err.description
Exit Do
End If
wscript.sleep 20
Loop
--------------------------------

after this line an error occurs
Error number -2147467259 : SlideShowView.State : Object does not
exist.
with the option "END WITH BLACK SLIDE" set there ist no problem at
all!!

please help!


My System SpecsSystem Spec
Old 10-23-2008   #2 (permalink)
Tom Lavedas


 
 

Re: Need help with powerpoint automation...

On Oct 22, 9:47*pm, "reinhold.fied...@xxxxxx"
<reinhold.fied...@xxxxxx> wrote:
Quote:

> the script found at msdn scripting guys does end with an error if the
> option "END WITH BLACK SLIDE" is "NOT" selected in the poperpoint
> option menue. can anybody help me?
> tested with pp2003 & pp2007
> codehttp://www.microsoft.com/technet/scriptcenter/scripts/office/ppt/ofpp....
>
> ------------------------------------------------------------------
> Const ppAdvanceOnTime = 2
> Const ppShowTypeKiosk = 3
> Const ppSlideShowDone = 5
>
> Set objPPT = CreateObject("PowerPoint.Application")
> objPPT.Visible = True
>
> Set objPresentation = objPPT.Presentations.Open("C:\test.ppt")
>
> 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
>
> Do Until objSlideShow.State = ppSlideShowDone
> * * * * *If err Then
> * * * * * * wscript.echo "Error number " & err & " : " & Err.description
> * * * * * * Exit Do
> * * * * * * * * End If
> * * * * * * * *wscript.sleep 20
> Loop
> --------------------------------
>
> after this line an error occurs
> Error number -2147467259 : SlideShowView.State : Object does not
> exist.
> with the option "END WITH BLACK SLIDE" set there ist no problem at
> all!!
>
> please help!
It would seem to me that there needs to be an "On Error Resume Next"
statement in there for this to work correctly, something like this ...

'...
On Error Resume Next
Do Until objSlideShow.State = ppSlideShowDone
If err.Number <> 0 Then
' And I don't think this next line is really necessary (or useful
except for debugging)
wscript.echo "Error number " & err.Number & " : " &
Err.description
Exit Do
End If
wscript.sleep 20
Loop

Now it won't show an error, regardless of how the presentation is set
up. The error still exists, but is handled by the procedure. Since
it's not fatal, it's just ignored.

(My other additions are only cosmetic, but I think they make the code
more understandable - easing later maintenance.)

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Excel does not die using automation .NET General
Powershell OLE Automation? PowerShell
Automation error 440 Vista General
Excel automation PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46