zoukankan      html  css  js  c++  java
  • netoffice添加新的slide

       网上很少关于netoffice添加slide的方法,后来用了VSTO添加的方法竟然可行,都是微软的,其实原理应该是一样的。具体代码如下:

    /// PowerPoint 应用程序对象
    /// </summary>
    private PowerPoint.Application Application { get; set; }
    /// <summary>
    /// PowerPoint 文档对象
    /// </summary>
    public PowerPoint.Presentation Presentation { get; set; }

      //这是添加一个新的 Presentations

    this.Presentation = this.Application.Presentations.Add(MsoTriState.msoTrue);
    this.Presentation.Slides.Add(1, PowerPoint.PpSlideLayout.ppLayoutText);

    //添加一个slide

    PowerPoint.Slide slide = this.Application.ActivePresentation.Slides.Add(this.Application.ActivePresentation.Slides.Count + 1, PowerPoint.PpSlideLayout.ppLayoutBlank);

    textbox = slide.Shapes.AddLabel(MsoTextOrientation.msoTextOrientationHorizontal,50, 30, 600, 20);
    textbox.TextFrame.TextRange.Text ="单选题";
    textbox.TextFrame.TextRange.Font.Size = 30;//设置文本字体大小
    // add a line
    slide.Shapes.AddLine(10, 80, 700, 80);

    //slide.Shapes.AddShape(MsoAutoShapeType.msoShapeSmileyFace, 200, 200, 250, 250);
    //题干部分
    textbox = slide.Shapes.AddLabel(MsoTextOrientation.msoTextOrientationHorizontal,50, 100, 600, 20);
    textbox.TextFrame.TextRange.Text = stem;
    textbox.TextFrame.TextRange.Font.Size = 24;//设置文本字体大小

    textbox = slide.Shapes.AddLabel(MsoTextOrientation.msoTextOrientationHorizontal, 50, 200, 600, 50);
    textbox.TextFrame.TextRange.Text ="A.";
    textbox.TextFrame.TextRange.Font.Size = 24;//设置文本字体大小
    textbox = slide.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, 70, 200, 600, 50);//向当前PPT添加文本框
    textbox.TextFrame.TextRange.Text = item1;//设置文本框的内容
    textbox.TextFrame.TextRange.Font.Size = 24;//设置文本字体大小
    textbox.TextFrame.TextRange.Font.Color.RGB = Color.Black.ToArgb();//设置文本颜色

    slide.Select();//这个是选中当前新增的slide

  • 相关阅读:
    html marque属性说明
    asp.net中转换web user control为custom web control
    免费的挖掘软件推荐(转)
    成为数据分析师的3个技能(转)
    基于数据库营销的433定律(转)
    ODS项目常见问题
    visual studio 2010 professional , premium, ultimate各版本功能对比
    C++异常处理之二 (How a VC++ compiler implements exception handling)
    仿函数(又名函数对象)与仿函数配接器
    Windows 异常处理(Structured Exception Handling)
  • 原文地址:https://www.cnblogs.com/songStar/p/8351526.html
Copyright © 2011-2022 走看看