代码:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using PPT = Microsoft.Office.Interop.PowerPoint; using System.IO; using System.Reflection; namespace WebPPT { public partial class WebForm1 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } public void Method() { string path; PPT.Application pptApp; PPT.Presentation pptDoc; path = @"d:/test.ppt"; //path = @"d:/test.pps"; pptApp = new PPT.Application(); if (File.Exists(path)) { File.Delete(path); } Object nothing = Missing.Value; pptDoc = pptApp.Presentations.Add(Microsoft.Office.Core.MsoTriState.msoFalse); PPT.PpSaveAsFileType format = PPT.PpSaveAsFileType.ppSaveAsDefault; //PPT.PpSaveAsFileType.ppSaveAsShow; pptDoc.SaveAs(path, format, Microsoft.Office.Core.MsoTriState.msoFalse); pptDoc.Close(); pptApp.Quit(); } protected void Button1_Click(object sender, EventArgs e) { Method(); } } }