当 SmartArt 位于占位符内时访问 SmartArt 形状 (PowerPoint 2007)
我需要在 PowerPoint 2007 中浏览智能艺术的每种形状。 当 shape.Type=msoSmartArt
时,我可以简单地浏览 shape.GroupItems 中的形状。
但是,当 shape.Type == msoPlaceholder && shape.PlaceholderFormat.ContainedType==msoSmartArt 那么 shape.GroupItems 为空。在这种情况下如何访问 Smart Art 形状?
我曾经认为 VBA 和 C# VSTO 基本相同。
嗯 - 这里有一个区别。我在实际的 VBA 中尝试了 Otaku 的代码,它似乎确实有效(很抱歉造成混乱,Otaku)。
但是,我的程序使用 C# VSTO 编写,并且:
foreach (Shape slideShape in pres.Slides[1].Shapes)
{
if (slideShape.Type != MsoShapeType.msoSmartArt && !(slideShape.Type == MsoShapeType.msoPlaceholder && slideShape.PlaceholderFormat.ContainedType==MsoShapeType.msoSmartArt))
continue;
GroupShapes shapes=slideShape.GroupItems;
Debug.WriteLine(shapes.Count);
}
确实产生: shapes.Count=0
(当形状类型为 Placeholder,且 containstype 为 SmartArt 时)。
有什么想法吗?
I need to go through each shape of a smart-art in PowerPoint 2007.
When shape.Type=msoSmartArt
then I could simply go through the shapes in shape.GroupItems.
However, when shape.Type == msoPlaceholder && shape.PlaceholderFormat.ContainedType==msoSmartArt
then shape.GroupItems
is empty. How can I access the Smart Art shapes in such a case?
I used to think of VBA and C# VSTO as basically the same.
Well - here there's a difference. I tried Otaku's code in actual VBA and it indeed seems to work (sorry for the confusion, Otaku).
However, my program is in C# VSTO, and:
foreach (Shape slideShape in pres.Slides[1].Shapes)
{
if (slideShape.Type != MsoShapeType.msoSmartArt && !(slideShape.Type == MsoShapeType.msoPlaceholder && slideShape.PlaceholderFormat.ContainedType==MsoShapeType.msoSmartArt))
continue;
GroupShapes shapes=slideShape.GroupItems;
Debug.WriteLine(shapes.Count);
}
Does produce: shapes.Count=0
(when the shape type is Placeholder, and containedtype is SmartArt).
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
GroupShapes
,例如:Use
GroupShapes
, like:我使用的解决方法是复制 SmartArt 并将其粘贴回来。
现在,粘贴的 SmartArt 的所有形状都包含在其 GroupItem 中。
使用这些后,我删除了粘贴的形状。
The workaround I use is copying the SmartArt and pasting it back.
the pasted SmartArt now has all its shapes in its GroupItems.
After working with these, I delete the pasted shape.