DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C# (http://www.daniweb.com/forums/forum61.html)
-   -   How to control Ms Powerpoint 2007 Slide show using C# 3.5? (http://www.daniweb.com/forums/thread162812.html)

bhavna_816 Dec 18th, 2008 2:44 am
How to control Ms Powerpoint 2007 Slide show using C# 3.5?
 
hi all,

i want to run the slide show say ten slides and then close it programaatically , but in my code given below it opens the slide show and closes immediately ... ..
please give me a solution to this problem


Microsoft.Office.Interop.PowerPoint.Application ppApp = new Microsoft.Office.Interop.PowerPoint.Application();
                                ppApp.Visible = MsoTriState.msoTrue;
                                Presentations ppPresens = ppApp.Presentations;
                                Presentation objPres = ppPresens.Open(fullPath, MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
                                Slides objSlides = objPres.Slides;
                                Microsoft.Office.Interop.PowerPoint.SlideShowWindows objSSWs;
                                Microsoft.Office.Interop.PowerPoint.SlideShowSettings objSSS;

                                //Run the Slide show
                                objSSS = objPres.SlideShowSettings;
                                objSSS.StartingSlide = 1;
                                objSSS.EndingSlide = objSlides.Count;
                                objSSS.Run();
                                objSSWs = ppApp.SlideShowWindows;

                                                                for (int i = objSSS.StartingSlide; i <= objSSS.EndingSlide; i++)
                                {
                                                                                System.Threading.Thread.Sleep(100);
                                       
                                }                               
                                //Close the presentation
                                objPres.Close();
                                while (System.Runtime.InteropServices.Marshal.ReleaseComObject(objPres) > 0) { };
                                objPres = null;

                                while (System.Runtime.InteropServices.Marshal.ReleaseComObject(ppPresens) > 0) { };
                                ppPresens = null;

                                ppApp.Quit();
                                while (System.Runtime.InteropServices.Marshal.ReleaseComObject(ppApp) > 0) { };
                                ppApp = null;

I have tried with
System.Threading.Thread.Sleep(10000);
but not worked.


All times are GMT -4. The time now is 5:28 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC