ここでは、Interop オブジェクトを使用しています。
private void mConvertPPT_To_Images(string sPPTFilePath, string sImagesDirectoryPath)
{
try
{
Microsoft.Office.Interop.PowerPoint.Application appPpt = new Microsoft.Office.Interop.PowerPoint.Application();
Microsoft.Office.Interop.PowerPoint.Presentation objActivePresentation
= appPpt.Presentations.Open(sPPTFilePath,
Microsoft.Office.Core.MsoTriState.msoCTrue,
Microsoft.Office.Core.MsoTriState.msoTriStateMixed,
Microsoft.Office.Core.MsoTriState.msoFalse);
//objActivePresentation.SaveAs(sImagesDirectoryPath, PpSaveAsFileType.ppSaveAsJPG, MsoTriState.msoFalse);
//objActivePresentation.Export(sImagesDirectoryPath + @"\Slide1.png", "png", 960, 720);
//objActivePresentation.SaveAs(sImagesDirectoryPath + "slide", PpSaveAsFileType.ppSaveAsTIF, MsoTriState.msoFalse);
int i = 0;
foreach (Microsoft.Office.Interop.PowerPoint.Slide objSlide in objActivePresentation.Slides)
{
//Names are generated based on timestamp.
//objSlide.Export("Slide" + i, "PNG", 960, 720);
objSlide.Export(sImagesDirectoryPath + @"\Slide" + i + ".GIF", "GIF", 960, 720);
i++;
}
objActivePresentation.Close();
appPpt.Quit();
}
catch (Exception ex)
{
throw;
}
}