简体   繁体   English

C#PowerPoint Interop多个幻灯片放映

[英]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) 我有一台将Powerpoint导出到网络文件夹的服务器(我知道Microsoft不推荐这样做,所以请给我保留这些)

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). 我的应用程序应该用于在大型电视上显示Powerpoint,因此,我希望连续不断地播放Powerpoint幻灯片(不闪烁)。 I have an event (FileSystemWatcher) that checks whenever a new file is created on that folder. 我有一个事件(FileSystemWatcher),该事件检查何时在该文件夹上创建新文件。 When it is, it opens with powerpoint and start the slide show. 当它打开时,它会以powerpoint打开并开始幻灯片放映。

Problem is if I start slide show without considering the old, it works nicely, a short hiccup but no flickering. 问题是,如果我在不考虑过时的情况下开始放映幻灯片,效果很好,打h时间短,但没有闪烁。 However then I have loads of powerpoint instances open. 但是然后我打开了许多powerpoint实例。

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. 找到解决方案(针对PowerPoint 2010)。首先为演示文稿1开始幻灯片放映,然后为它检索slideshowview。 Start slide show for presentation 2, then close slide show for presentation 1 with slideshowview, then close presentation for presentation 1. 开始演示文稿2的幻灯片放映,然后使用slideshowview关闭演示文稿1的幻灯片放映,然后关闭演示文稿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;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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