Click here to Skip to main content
Rate this: bad
good
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 21:10pm
Edited 22-Dec-12 1: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 at 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
0 Zoltán Zörgő 220
1 Sergey Alexandrovich Kryukov 180
2 Peter Leow 160
3 BillWoodruff 85
4 bling 80
0 Sergey Alexandrovich Kryukov 9,543
1 OriginalGriff 6,901
2 Peter Leow 4,737
3 Zoltán Zörgő 4,404
4 CHill60 2,932


Advertise | Privacy | Mobile
Web04 | 2.8.150129.1 | Last Updated 22 Dec 2012
Copyright © CodeProject, 1999-2015
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