当 SmartArt 位于占位符内时访问 SmartArt 形状 (PowerPoint 2007)

发布于 2024-09-15 23:23:00 字数 879 浏览 4 评论 0原文

我需要在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不必你懂 2024-09-22 23:23:00

使用GroupShapes,例如:

Sub GetSAfromPlaceholder()
    Dim ap As Presentation: Set ap = ActivePresentation
    Dim sl As Slide: Set sl = ap.Slides(2)
    Dim sh As Shape: Set sh = sl.Shapes(2)
    Dim gsh As GroupShapes: Set gsh = sh.GroupItems
    If sh.Type = msoPlaceholder Then
        If sh.PlaceholderFormat.ContainedType = msoSmartArt Then
        Debug.Print "SmartArt Shape Count: " & gsh.Count
          For i = 1 To gsh.Count
            If gsh(i).TextFrame.HasText Then
                Debug.Print gsh(i).TextFrame.TextRange.Text
            End If
            Next
        End If
    End If
End Sub

Use GroupShapes, like:

Sub GetSAfromPlaceholder()
    Dim ap As Presentation: Set ap = ActivePresentation
    Dim sl As Slide: Set sl = ap.Slides(2)
    Dim sh As Shape: Set sh = sl.Shapes(2)
    Dim gsh As GroupShapes: Set gsh = sh.GroupItems
    If sh.Type = msoPlaceholder Then
        If sh.PlaceholderFormat.ContainedType = msoSmartArt Then
        Debug.Print "SmartArt Shape Count: " & gsh.Count
          For i = 1 To gsh.Count
            If gsh(i).TextFrame.HasText Then
                Debug.Print gsh(i).TextFrame.TextRange.Text
            End If
            Next
        End If
    End If
End Sub
错々过的事 2024-09-22 23:23:00

我使用的解决方法是复制 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文