如何解决有没有一种方法可以在PowerPoint中将SmartArt与C#一起使用而无需调用SmartArtLayouts的应用程序?
我正在尝试使用C#Windows窗体应用程序在PowerPoint中添加SmartArt。我发现以下代码仅在第二行为pptApplication.Presentations.Add(MsoTriState.msoTrue);
时有效
我的用户习惯于在不打开的情况下在后台创建PPT,因此我想找到一种不必保持WithWindow为true的方法。这可能吗?
当前(如果WithWindow设置为false),我将收到错误System.Runtime.InteropServices.COMException:'应用程序(未知成员):对象不存在。在呼叫pptApplication.SmartArtLayouts[1]
// Create the Presentation File
Microsoft.Office.Interop.PowerPoint.Application pptApplication = new Microsoft.Office.Interop.PowerPoint.Application();
Presentation pptPresentation = pptApplication.Presentations.Add(MsoTriState.msoFalse);
CustomLayout customLayout = pptPresentation.SlideMaster.CustomLayouts[PpSlideLayout.ppLayoutText];
// Create new Slide
var slides = pptPresentation.Slides;
var slide = slides.AddSlide(1,customLayout);
Microsoft.Office.Interop.PowerPoint.Shape shp = slide.Shapes.AddSmartArt(pptApplication.SmartArtLayouts[1],9,11);
var smartshp = shp.SmartArt;
var txtrg = smartshp.Nodes[1].TextFrame2.TextRange;
txtrg.Text = "test1";
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。