/*
   create some kind of shapes with PowerPoint
   taken from Example02.cs
*/
private void Example02Main()
{
   // start powerpoint 
   PowerPoint.Application powerApplication = new PowerPoint.Application();
   
   // add a new presentation with one new slide
   PowerPoint.Presentation presentation = 
powerApplication.Presentations.Add(MsoTriState.msoTrue); PowerPoint.Slide slide = presentation.Slides.Add(1, PpSlideLayout.ppLayoutBlank); // add a label PowerPoint.Shape label = slide.Shapes.AddLabel(
MsoTextOrientation.msoTextOrientationHorizontal,
10, 10, 600, 20); label.TextFrame.TextRange.Text =
"This slide and created Shapes are created by NetOffice example."; // add a line slide.Shapes.AddLine(10, 80, 700, 80); // add a wordart slide.Shapes.AddTextEffect(MsoPresetTextEffect.msoTextEffect9, "This a WordArt",
"Arial", 20, MsoTriState.msoTrue,
MsoTriState.msoFalse, 10, 150); // add a star slide.Shapes.AddShape(MsoAutoShapeType.msoShape24pointStar, 200, 200, 250, 250); // save the document string fileExtension = GetDefaultExtension(powerApplication); string documentFile = string.Format("{0}\\Example02{1}",
Application.StartupPath,
fileExtension);
presentation.SaveAs(documentFile,
PpSaveAsFileType.ppSaveAsDefault,
MsoTriState.msoTrue); // close power point and dispose reference powerApplication.Quit(); powerApplication.Dispose(); FinishDialog fDialog = new FinishDialog("Presentation saved.", documentFile); fDialog.ShowDialog(this); } /// <summary> /// returns the valid file extension for the instance. for example ".ppt" or ".pptx" /// </summary> /// <param name="application">the instance</param> /// <returns>the extension</returns> private static string GetDefaultExtension(PowerPoint.Application application) { double Version = Convert.ToDouble(application.Version, CultureInfo.InvariantCulture); if (Version >= 12.00) return ".pptx"; else return ".ppt"; }

Last edited Jun 13, 2012 at 1:08 PM by SebastianDotNet, version 8

Comments

No comments yet.