合并2个PPT【Access,word同理】(来自www.yesur.com)

来源:互联网 发布:淘宝网店女装推广方案 编辑:程序博客网 时间:2024/05/16 19:51

using System;
using System.Xml;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using PowerPoint;
using Microsoft.Office;
using Microsoft.Office.Core;
namespace cmd
{
 /// <summary>
 /// opPPT 的摘要说明。
 /// </summary>
 public class opPPT : System.Web.UI.Page
 {
  private void Page_Load(object sender, System.EventArgs e)
  {
   // 在此处放置用户代码以初始化页面
   PowerPoint.ApplicationClass oPP =  new PowerPoint.ApplicationClass();
   oPP.Visible = MsoTriState.msoTrue;
   PowerPoint.Presentations oPresSet = oPP.Presentations;
   PowerPoint._Presentation oPres = oPresSet.Open("c://a.ppt",MsoTriState.msoFalse, MsoTriState.msoFalse,MsoTriState.msoTrue);
   oPres.Slides.InsertFromFile("c://b.ppt",oPres.Slides.Count,1,-1);

   // Run

   oPres.SaveAs("c://yesur.ppt",PowerPoint.PpSaveAsFileType.ppSaveAsDefault,MsoTriState.msoCTrue);    

   // Quit PowerPoint and clean up.
   oPres.Close();
   System.Runtime.InteropServices.Marshal.ReleaseComObject (oPres);
   oPres = null;
   System.Runtime.InteropServices.Marshal.ReleaseComObject (oPresSet);
   oPresSet = null;
   oPP.Quit();
   System.Runtime.InteropServices.Marshal.ReleaseComObject (oPP);
   oPP = null;
  
  }

  #region Web 窗体设计器生成的代码
  override protected void OnInit(EventArgs e)
  {
   //
   // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
   //
   InitializeComponent();
   base.OnInit(e);
  }
  
  /// <summary>
  /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  /// 此方法的内容。
  /// </summary>
  private void InitializeComponent()
  {   
   this.Load += new System.EventHandler(this.Page_Load);
  }
  #endregion
 }
}