2011-03-18 59 views
3

我是C#和Windows編程的初學者。我已經編寫了一項服務,使用microsoft.office.interop.powerpoint庫提供的slide.export方法將PowerPoint文件轉換爲單張幻燈片圖像。我能夠獲得所有的幻燈片,但其中一些似乎被打破,我看到"Image cannot be displayed. Memory exceeded"或類似的。我認爲這是內存不足,然後只用一個幻燈片(其圖像被破壞)嘗試了它,讓我驚愕的是,我發現單個圖像也被破壞了。C#MS Office PPT到圖像轉換

我使用導出錯誤還是應該傳遞不同的參數比我已經通過?我將粘貼下面的代碼。

Microsoft.Office.Interop.PowerPoint.Application appPpt 
    = new Microsoft.Office.Interop.PowerPoint.Application(); 

Microsoft.Office.Interop.PowerPoint.Presentation objActivePresentation 
    = appPpt.Presentations.Open(strFilePath, 
           Microsoft.Office.Core.MsoTriState.msoCTrue, 
           Microsoft.Office.Core.MsoTriState.msoTriStateMixed, 
           Microsoft.Office.Core.MsoTriState.msoFalse); 

foreach (Microsoft.Office.Interop.PowerPoint.Slide objSlide 
                in objActivePresentation.Slides) 
{ 
    //Names are generated based on timestamp. 
    objSlide.Export(slideName, "PNG", 960, 720); 
    objSlide.Export(slideNameMedium, "JPG", 307, 231); 
    objSlide.Export(slideNametn, "JPG", 150, 113); 
} 

我在這裏需要幫助。提前致謝。

回答

4

嘗試另存爲。 希望它有幫助.....