[英]how to split a *.pptx file into multiple slide in visual studio 2013 by the help of C#?
[英]C# open PPTX file to a specific slide index
我正在考虑将 .pptx PowerPoint 文件打开到特定幻灯片索引。 对于这个例子,让我们说幻灯片 3。
我有打开文件的代码,但我无法让它自己打开到幻灯片 3。
打开pptx文件的代码:
string file_path = @"C:\Users\Me\Desktop\Test_Folder\myppt.pptx";
Microsoft.Office.Interop.PowerPoint.Application pptApp = new Microsoft.Office.Interop.PowerPoint.Application();
Microsoft.Office.Core.MsoTriState ofalse = Microsoft.Office.Core.MsoTriState.msoFalse;
Microsoft.Office.Core.MsoTriState otrue = Microsoft.Office.Core.MsoTriState.msoTrue;
pptApp.Visible = otrue;
pptApp.Activate();
Microsoft.Office.Interop.PowerPoint.Presentations ps = pptApp.Presentations;
Microsoft.Office.Interop.PowerPoint.Presentation p = ps.Open(file_path, ofalse, ofalse, otrue);
System.Diagnostics.Debug.Print(p.Windows.Count.ToString());
我已经做了一些阅读,我解决这个问题的想法包括添加一个地方p.Slides[2]
进来将它发送到幻灯片索引 3(认为它像数组一样变成 0, 1 ,2,我可以这里错了)。 我只是不知道将它放在我的代码块中的哪个位置,或者是否有不同的方式,我还没有看到。
根据注释中的p.Open
,在上面代码中的p.Open
行之后添加两行,电源点打开到正确的幻灯片。
这两行是:
p.SlideShowSettings.Run()
p.SlideShowWindow.View.GotoSlide(3, MsoTriState.msoFalse);
功能代码:
string file_path = @"C:\Users\Me\Desktop\Test_Folder\myppt.pptx";
Microsoft.Office.Interop.PowerPoint.Application pptApp = new Microsoft.Office.Interop.PowerPoint.Application();
Microsoft.Office.Core.MsoTriState ofalse = Microsoft.Office.Core.MsoTriState.msoFalse;
Microsoft.Office.Core.MsoTriState otrue = Microsoft.Office.Core.MsoTriState.msoTrue;
pptApp.Visible = otrue;
pptApp.Activate();
Microsoft.Office.Interop.PowerPoint.Presentations ps = pptApp.Presentations;
Microsoft.Office.Interop.PowerPoint.Presentation p = ps.Open(file_path, ofalse, ofalse, otrue);
p.SlideShowSettings.Run()
p.SlideShowWindow.View.GotoSlide(3, MsoTriState.msoFalse);
System.Diagnostics.Debug.Print(p.Windows.Count.ToString());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.