首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >互操作Powerpoint,

互操作Powerpoint,
EN

Stack Overflow用户
提问于 2017-04-21 14:44:48
回答 1查看 1.1K关注 0票数 0

我想在powerpoint中插入一张图片,我正面临以下错误:

(1.解决方案异常:CustomLayout(未知成员):超出范围的整数。36不在1至11的有效范围内。

此问题位于代码的这一部分:

代码语言:javascript
复制
PowerPoint.CustomLayout Cus01 = pr01.SlideMaster.CustomLayouts[PowerPoint.PpSlideLayout.ppLayoutPictureWithCaption];

pplayoutPictureWithCaption的号码是36。

有什么主意吗?

代码语言:javascript
复制
if (trigger[0] == true)
{
    //Create a project
    Microsoft.Office.Interop.PowerPoint.Application app = new Microsoft.Office.Interop.PowerPoint.Application();
    app.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;

    //Create a presentation in thie project
    Microsoft.Office.Interop.PowerPoint.Presentations pre = app.Presentations;
    Microsoft.Office.Interop.PowerPoint.Presentation pr01 = pre.Add(Microsoft.Office.Core.MsoTriState.msoTrue);

    Microsoft.Office.Interop.PowerPoint.Presentation pr02 = app.ActivePresentation;

    //Create a slide in the project
    Microsoft.Office.Interop.PowerPoint.Slides sl = pr02.Slides;
    Microsoft.Office.Interop.PowerPoint.CustomLayout Cus01 = pr01.SlideMaster.CustomLayouts[Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutPictureWithCaption];
    Microsoft.Office.Interop.PowerPoint.Slide sl01 = pr02.Slides.AddSlide(1, Cus01);


    //Insert Picture
    Microsoft.Office.Interop.PowerPoint.Shape shape = sl01.Shapes[2];
    sl01.Shapes.AddPicture("D:\\AliceProject\\sd.jpg", Microsoft.Office.Core.MsoTriState.msoTrue, Microsoft.Office.Core.MsoTriState.msoFalse, 1, 1, 3, 3);
}
EN

回答 1

Stack Overflow用户

发布于 2018-11-27 10:01:25

在使用NetOffice + powerpoint 2013时,我也遇到了同样的错误。但是,如果我在创建幻灯片时直接设置类型,它就会工作。

代码语言:javascript
复制
presentation.Slides.Add(presentation.Slides.Count + 1, PpSlideLayout.ppLayoutPictureWithCaption);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43545630

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档