Click here to Skip to main content
12,350,723 members (24,337 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C#
I am trying to open ppt from "c:\myppts\first.ppt" with the below code. But i am getting the exception.
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 21-Dec-12 20:10pm
Edited 22-Dec-12 0:15am
v2

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Try with following code
    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);
    }
  Permalink  
v2
Comments
Member 9305115 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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160621.1 | Last Updated 22 Dec 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100