要實現PPT轉圖片,首先須要引用兩個DLL。app
我這裏用的這個這個版本ide
Microsoft.Office.Interop.PowerPoint 12.0ui
Microsoft Office 12.0 object Libraryspa
以下圖:code
代碼以下:orm
private void pptToImg(string pptPath, string imgPath) { var app = new Microsoft.Office.Interop.PowerPoint.Application(); var ppt = app.Presentations.Open(pptPath, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse); var index = 0; var fileName = Path.GetFileNameWithoutExtension(pptPath); foreach (Microsoft.Office.Interop.PowerPoint.Slide slid in ppt.Slides) { ++index; //設置圖片大小 slid.Export(imgPath+string.Format("page{0}.png",index.ToString()), "png", 1024, 768); //根據屏幕尺寸。設置圖片大小 //slid.Export(imgPath+string.Format("page{0}.jpg",index.ToString()), "jpg", Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height); } //釋放資源 ppt.Close(); app.Quit(); GC.Collect(); }