【问题标题】:Getting error when adding programmatically a custom smartart shape in PowerPoint在 PowerPoint 中以编程方式添加自定义 smartart 形状时出错
【发布时间】:2015-01-16 19:23:21
【问题描述】:

我创建了 3 个 smartart 形状,并将它们放入文件夹:“C:\Users...\AppData\Roaming\Microsoft\Templates\SmartArt Graphics”,PowerPoint 成功加载它们。您可以从 UI 调用它们,但是如果在打开 PowerPoint 后开始时,我以编程方式将 smartart 形状添加到幻灯片中,我总是会收到以下错误:

“指定集合的​​索引超出范围”

但是,如果我先从 UI 添加我的 smartart 形状,然后我想从代码中添加我的 smartart 形状,则不会出现错误。

我的 smartart 形状: smartart resources

我的代码是:

Microsoft.Office.Core.SmartArtLayout myLayout = null; 尝试 { myLayout = PowerPointApp.SmartArtLayouts["SmartArtABS3"]; } 捕捉(例外前) { MessageBox.Show(ex.Message); 问题布局=空; } 如果(问题布局!= null) { PowerPoint.Shape smShape = allShapes.AddSmartArt(myLayout, left, top, width, height); //..... }

注意:我使用的是 VS Ultimate 2013、PowerPoint 2013、C#、Add-In-Express

【问题讨论】:

    标签: vba vsto powerpoint office-interop office-addins


    【解决方案1】:

    很确定您不能使用名称作为索引,您必须使用索引(长)

    如果您不知道它会遍历名称,直到找到匹配项。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-01-14
      • 2011-03-23
      • 1970-01-01
      • 2021-06-09
      • 1970-01-01
      • 1970-01-01
      • 2014-03-07
      • 1970-01-01
      相关资源
      最近更新 更多