我想在powerpoint中插入一张图片,我正面临以下错误:
(1.解决方案异常:CustomLayout(未知成员):超出范围的整数。36不在1至11的有效范围内。
此问题位于代码的这一部分:
PowerPoint.CustomLayout Cus01 = pr01.SlideMaster.CustomLayouts[PowerPoint.PpSlideLayout.ppLayoutPictureWithCaption];pplayoutPictureWithCaption的号码是36。
有什么主意吗?
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);
}发布于 2018-11-27 10:01:25
在使用NetOffice + powerpoint 2013时,我也遇到了同样的错误。但是,如果我在创建幻灯片时直接设置类型,它就会工作。
presentation.Slides.Add(presentation.Slides.Count + 1, PpSlideLayout.ppLayoutPictureWithCaption);https://stackoverflow.com/questions/43545630
复制相似问题