我正在使用C#开发Windows Forms Application,在其中打开PowerPoint。 打开PowerPoint幻灯片时,此代码中出现COM Interop Exception。
try
{
Microsoft.Office.Interop.PowerPoint.Application ppApp = new
Microsoft.Office.Interop.PowerPoint.Application();
System.Threading.Thread.Sleep(2000);
//ppApp.Visible = MsoTriState.msoTrue;
String pathtoEXE = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase);
Presentations ppPresens = ppApp.Presentations;
Presentation objPres = ppPresens.Open(pathtoEXE + "\\BC1X4A1Ien.pptx", 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.Run();
//objSSWs = ppApp.SlideShowWindows;
//while (objSSWs.Count >= 1)
// System.Threading.Thread.Sleep(40);
//Close the presentation without saving changes and quit PowerPoint
//objPres.Close();
//ppApp.Quit();
}
catch (Exception ex)
{
ProcessStartInfo objProcess = new ProcessStartInfo(@"E4U-S-Type-E200-
help.exe");
objProcess.UseShellExecute = false;
objProcess.RedirectStandardOutput = true;
Process.Start(objProcess);
}