如何将只读ppt保存为pdf?

时间:2012-12-03 14:59:04

标签: c#-4.0 asp.net-4.0 office-interop

当我试图将只读ppt / pptx保存到pdf时我得到了一个msg,如下所示

enter image description here

下面是我的代码:

        Microsoft.Office.Interop.PowerPoint.Application pptApplication = new Microsoft.Office.Interop.PowerPoint.Application();
        pptApplication.DisplayAlerts = PpAlertLevel.ppAlertsNone;
        Microsoft.Office.Interop.PowerPoint.Presentation pptPresentation = pptApplication.Presentations.Open("E:\\Share Box\\data.pptx", MsoTriState.msoTriStateMixed,
        MsoTriState.msoFalse, MsoTriState.msoFalse);

        string temp = pptPresentation.ReadOnly.ToString();

        pptPresentation.SaveAs("E:\\Share Box\\"+DateTime.Now.Second.ToString(), PpSaveAsFileType.ppSaveAsPDF, MsoTriState.msoTrue);

        pptPresentation.Close();

        Marshal.FinalReleaseComObject(pptPresentation);
        pptPresentation = null;
        pptApplication.Quit();

        Marshal.FinalReleaseComObject(pptApplication);
        pptApplication = null;

        GC.Collect();

任何人都可以帮我解决这个问题。

1 个答案:

答案 0 :(得分:0)

我尝试了这段代码并且工作正常。为此,我使用了从中下载的互操作程序集 http://www.microsoft.com/en-in/download/details.aspx?id=3508

请同时查看

http://support.microsoft.com/kb/873433