Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to open ppt from "c:\myppts\first.ppt" with the below code. But i am getting the exception.
C#
objApp = new Microsoft.Office.Interop.PowerPoint.Application { Visible = MsoTriState.msoTrue };
objPresSet = objApp.Presentations;
objPres = objPresSet.Open("c:\myppts\first.ppt");


But i am getting the below exception:
COMException: PowerPoint could not open the file.
Posted
Updated 22-Dec-12 0:15am
v2

1 solution

Try with following code
C#
    private void btnPPT_Click(object sender, EventArgs e)
    {
      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(@"D:\AQHA\Wegbeschreibung\Reithallenplan.pptx", ofalse, ofalse, otrue);
      System.Diagnostics.Debug.Print(p.Windows.Count.ToString());
      MessageBox.Show(pptApp.ActiveWindow.Caption);
    }
 
Share this answer
 
v2
Comments
Pradeepkumar patil sonu 22-Dec-12 4:07am    
tried same error getting

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900