Error When Converting ppt or pptx file into pdf format

Jul 25, 2013 at 1:09 PM
Edited Jul 25, 2013 at 1:09 PM
Hello

When i try to converting power point file into pdf format
I get following Error

Error HRESULT E_FAIL has been returned from a call to a COM component.

My Code is :
       string sourcePath = Server.MapPath("Document") + "\\imedisearch.ppt";

        string targetPath = Server.MapPath("ResultDocument") + "\\Simple.pdf";
        Microsoft.Office.Interop.PowerPoint.Application application = new Microsoft.Office.Interop.PowerPoint.Application();
        Microsoft.Office.Interop.PowerPoint.Presentation persentation = new Microsoft.Office.Interop.PowerPoint.Presentation();
        persentation = application.Presentations.Open(sourcePath, MsoTriState.msoTrue);
        persentation.SaveAs(targetPath, Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsPDF, Microsoft.Office.Core.MsoTriState.msoTrue);
        lblResult.Text = "File convert from PPT/PPTX to PDF successfully..";