现在的位置: 首页 > 综合 > 正文

使用C#创建PowerPoint文档

2018年05月14日 ⁄ 综合 ⁄ 共 865字 ⁄ 字号 评论关闭

using System;

using System.Collections.Generic;

using System.IO;

using System.Text;

using PPT = Microsoft.Office.Interop.PowerPoint;  //11.0-2003,12.0-2007

namespace CreatePPTDemo

{

  calss Program

  {

    static void Main(string[] args)

    {

      string path;

      PPT.Application pptApp;

      PPT.Presentation pptDoc;

      path = @"d:/test.ppt";                           //path = @"d:/test.pps";

      pptApp = new PPT.ApplicationClass();

      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();

    }

  }

抱歉!评论已关闭.