using Microsoft.Office.Core;
using Microsoft.Office.Interop.PowerPoint;
 
 
public bool ConvertPics(string sourcePath, string targetPath, PpSaveAsFileType targetFileType)
        {
            bool result;
            object missing = Type.Missing;
            Microsoft.Office.Interop.PowerPoint.Application application = null;
            // Microsoft.Office.Interop.Word.Application 
            Presentation persentation = null;
            Presentation persentationCopy = null;
            try
            {
                Thread.Sleep(2000);
                application = new Microsoft.Office.Interop.PowerPoint.Application();
                persentation = application.Presentations.Open(sourcePath, MsoTriState.msoTrue, MsoTriState.msoFalse, MsoTriState.msoFalse);
                //   persentation.SaveAs(targetPath, targetFileType, Microsoft.Office.Core.MsoTriState.msoTrue);                    //整个ppt的文件转换为其他的格式
                //  persentation.Slides[1].Export(targetPath + "\\ppt.jpg", "JPG", 800, 600);                   //将ppt中的某张转换为图片文件
                persentation.SaveAs(targetPath, targetFileType, Microsoft.Office.Core.MsoTriState.msoTrue);    //整个ppt的文件转换为其他的格式
                result = true;
            }
            catch (Exception ex)
            {
                ex.ToString();
                result = false;
                new SSP.School.BLL.Temp().AddMessage("sourcePath=" + sourcePath + ";targetPath=" + targetPath + ";" + ex.ToString(), " PPT转码服务异常(ConvertPics)");
            }
            finally
            {
                if (persentation != null)
                {
                    persentation.Close();
                    persentation = null;
                }
                if (application != null)
                {
                    application.Quit();
                    application = null;
                }
                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();
                GC.WaitForPendingFinalizers();
            }
            return result;
        }
 
  
 
  <identity impersonate="true" userName="administrator" password="123456" />