如何在PowerPoint VBA中选择全部?

发布于 2025-01-26 05:26:46 字数 200 浏览 2 评论 0原文

我已经挣扎了一段时间,以找到VBA代码来选择演示文稿的所有幻灯片和所有形状(由于某种原因,这似乎没有人的兴趣)。我试图设置所有幻灯片的范围,然后选择该范围的所有形状,但这不起作用。我还尝试通过幻灯片循环幻灯片并积累选择(msofalse),但是为此,您还需要激活每张幻灯片,而我无法做到这一点。 我认为立即选择所有幻灯片和形状对于操纵字体或运行完整咒语检查很有用。您的帮助将不胜感激!!

I have been struggling for a while to find a VBA code to select all the slides and all the shapes of a presentation (for some reason this seems to be of no one's interest). I have tried to set up a range with all the slides and then select all the shapes of the range, but that does not work. I also try looping slide by slide and accumulate the selection (msoFalse), but for that you also need to activate each slide and I was unable to do that.
I think selecting all the slides and shapes at once is useful to manipulate the fonts or run a full spell check. Your help would be really appreciated!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

煞人兵器 2025-02-02 05:26:46

通常可以避免在VBA中选择对象。这是不可靠和缓慢的。相反,循环遍历每个幻灯片上的每个形状并执行所需的任何操作:

Sub DoStuffToShapes()
    Dim oSlide as Slide
    Dim oShape as Shape

    For each oSlide in ActivePresentation.Slides
        For each oShape in oSlide.Shapes
            'Do stuff to the shape
        Next oShape
    Next oSlide
End Sub

如果您创建了一个字体主题并将其应用于幻灯片主和布局,则通常更容易,更快地通过修改主题和/或Master来更改字体而不是使用VBA。拼写检查也不需要VBA。

Selecting objects in VBA is generally to be avoided. It's unreliable and slow. Instead, loop through every shape on every slide and perform whatever operation you need:

Sub DoStuffToShapes()
    Dim oSlide as Slide
    Dim oShape as Shape

    For each oSlide in ActivePresentation.Slides
        For each oShape in oSlide.Shapes
            'Do stuff to the shape
        Next oShape
    Next oSlide
End Sub

If you've created a font theme and applied it to the Slide Master and Layouts, it's usually easier and faster to change fonts by modifying the theme and/or master rather than using VBA. VBA isn't needed for a spellcheck either.

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