COM Interop Exception while opening PowerPoint File in Windows Forms

-2

I am developing a Windows Forms Application using C#, in which I am opening PowerPoint. I am getting COM Interop Exception in this code while opening PowerPoint Slides.

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);
}

See the end of this message for details on invoking just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text ************** System.Runtime.InteropServices.COMException (0x80004005): PowerPoint could not open the file.

c#
winforms
powerpoint
asked on Stack Overflow Jul 19, 2019 by Muhammad Usman • edited Aug 2, 2019 by R.J. Dunnill

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0