简体   繁体   中英

C# powerpoint interop multiple slide shows

I have a server that exports powerpoints to a network folder (I know microsoft does not recommend it, so please spare me those)

My application should be used to display powerpoints on large TVs, and thus I want to have a continious flow of powerpoints slide shows (no flickering). I have an event (FileSystemWatcher) that checks whenever a new file is created on that folder. When it is, it opens with powerpoint and start the slide show.

Problem is if I start slide show without considering the old, it works nicely, a short hiccup but no flickering. However then I have loads of powerpoint instances open.

I tried to start slide show, and close old instances, but when I do, the new slide show is closed/exited too.

Any suggestions?

The code for the working, but not very memory friendly....

PPT.Application oPpt = new PPT.Application();
PPT.Presentations oPresSet = oPpt.Presentations;
PPT.Presentation oPres = oPresSet.Open(e.FullPath, Microsoft.Office.Core.MsoTriState.msoTrue, Microsoft.Office.Core.MsoTriState.msoTrue, Microsoft.Office.Core.MsoTriState.msoTrue);
PPT.Slides oSlides = oPres.Slides;
PPT.SlideShowSettings objSSS = oPres.SlideShowSettings;

objSSS.Run();

Found the solution (for powerpoint 2010) First start slide show for presentation 1, then I retrieve the slideshowview for it. Start slide show for presentation 2, then close slide show for presentation 1 with slideshowview, then close presentation for presentation 1.

In Code (continuing on my code from above)

objSSS.Run();
PPT.SlideShowView oSlideView = oPres.SlideShowWindow.View;


if (oldPPTPres != null && oldPPTView != null)
{
     oldPPTView.Exit();

     oldPPTPres.Close();
}

oldPPTView = oSlideView;
oldPPTPres = oPres;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM