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

  • 相关阅读:
    路飞学城Python-Day48
    路飞学城Python-Day46
    路飞学城Python-Day43
    路飞学城Python-Day42
    路飞学城Python-Day40(第四模块复习题)
    路飞学城Python-Day39(第四模块复习题)
    python小练习
    微信小程序常见错误及基本排除方法
    CSS文本样式
    小程序-广告轮播/控制属性
  • 原文地址:https://www.cnblogs.com/songStar/p/8351526.html
Copyright © 2011-2022 走看看