我对C#完全陌生。使用Microsoft.Office.Interop.PowerPoint命名空间,我希望能够从代码中启动PowerPoint演示文稿。有一条路径和一个完成的演示文稿,我希望它能自动全屏启动。
我该怎么做? 谢谢。
答案 0 :(得分:0)
试试这个:
using Microsoft.Office.Core;
using Microsoft.Office.Interop.PowerPoint;
using PPT = Microsoft.Office.Interop.PowerPoint;
namespace PowerPointLauncher
{
public void StartPresentation()
{
PPT.Application app = new PPT.Application();
//optionally on SlideShowEnd close all powerpoint windows created by your application (app)
app.SlideShowEnd += App_SlideShowEnd;
var pres = app.Presentations.Open("d:\\test.ppt", MsoTriState.msoTrue, MsoTriState.msoFalse, MsoTriState.msoTrue);
app.ActivePresentation.SlideShowSettings.Run();
}
private void App_SlideShowEnd(Presentation Pres)
{
foreach (DocumentWindow window in Pres.Application.Windows)
{
window.Close();
}
}
}