Help with win32com problem

Mark Hammond mhammond at skippinet.com.au
Sat Aug 17 02:14:31 CEST 2002


This is probably how powerpoint is designed.  You will probably need to 
hook powerpoint events so your code knows when the slideshow has 
finished so it can start the next one.  See 
win32com\test\testMSOfficeEvents.py for an example.

Mark.

- c o v e n t r y - wrote:
> Hello,
>   I'm doing COM automation to force MS Powerpoint to show a variety of 
> presentations.  When run, my script walks-through all the .ppt files
> located in a specific directory.  The problem I'm running into is that 
> if I set my script to loop indefinetly, it does not block on the COM 
> automation calls to powerpoint to run a presentation.  I've tried 
> modifying the clsctx used when I start Powerpoint with a document, but 
> can't seem to get the python process to block on the .Run() call...
> here is the relevant section of the script.  When run in its current 
> form, it causes the machine to flip-between all available presentations 
> so fast it creates a strobe effect on-screen (at least on my machine).
> If I don't use the while 1: loop, the code runs fine, but of course, it 
> doesn't loop.  Any sugestions?
> 
> import glob, win32com.client, pythoncom
> 
> ## loop forever!
> while 1:
>   ## reload ppt files each time we start presenting.
>   pptFiles = glob.glob('c:\*.ppt')
>   ## now show each ppt file.  each file must have
>   ## slide transitions set to auto-advance after a period fo time.
>   ### otherwise, this will lock up!
>   for pptFile in pptFiles:
>     ## regardless of which clsctx I use, I get the same result on the
>     ## next line...
>     PPT = 
> win32com.client.GetObject(pptFile,clsctx=pythoncom.CLSCTX_LOCAL_SERVER)
>     ## the following line does not block.
>     ## this can cause a major problem.  the 's =' is not needed,
>     ## but I wanted to see if an assignment would delay action...
>     ## it didn't.
>     s = PPT.SlideShowSettings.Run()
>     ## attempting to do a .Close() or a .Exit() does nothing meaningful
>     ## since the script continues to run...
> 
> 
> =======================
> Please help, any ideas would be appreciated!
>     
> 
> 




More information about the Python-list mailing list