using System;
using System.Collections.Generic;
using Sytem.Text;
using System.IO;
using PPT = Microsoft.Office.Interop.PowerPoint;
using System.Reflection;
namespace WritePPTDemo
{
class Program
{
static void Main(string[] args)
{
string path;
PPT.Application pptApp;
PPT.Presentation pptDoc;
path = @"d:/test.ppt";
pptApp = new PPT.ApplicationClass();
if(File.Exists(path))
{
File.Delete(path);
}
Object nothing = Missing.Value;
pptDoc = pptApp.Presentations.Add(Microsoft.Office.Core.msoTriState.msoFalse);
pptDoc.Slides.Add(1,Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayouText);
string text = "示例文本";
foreach(PPT.Slide slide in pptDoc.Slides)
{
foreach(PPT.Shape shape in slide.Shapes)
{
shape.TextFrame.TextRange.InsertAfter(text);
}
}
/*
//添加图片
pptDoc.Slides.Add(1,Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayouBlank);
string pic = @"d:/test.bmp";
foreach(PT.Slide slide int pptDoc.Slides)
{
slide.Shape.AddPicture(pic,Microsoft.Office.Core.MsoTriState.msoFalse,
Microsoft.Office.Core.MsoTriState.msoTure,150,150,300,200);
}
*/
PPT.PpSaveAsFileType format = PPT.PpSaveAsFileType.ppSaveAsDefault;
pptDoc.SaveAs(path,format,Microsoft.Office.Core.MsoTriState.msoFalse);
pptDoc.Close();
pptApp.Quit();
}
}
}