PowerPoint vba - 对于 MasterView 中每个布局中的每个形状

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4594291/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 12:28:08  来源:igfitidea点击:

PowerPoint vba - For each shape in each Layout in MasterView

vbapowerpointpowerpoint-vba

提问by Kenny Bones

I'm trying to programatically change the language of each shape in each customlayout in a PowerPoint template and I can't figure out how to do this. I've done it before, but I can't find the macro anymore so I don't really know how I did it. I've been able to select each custom layout though. But I need to loop through each textbox in each layout and select the language as well. My problem is targetting each shape. How do I do this?

我正在尝试以编程方式更改 PowerPoint 模板中每个自定义布局中每个形状的语言,但我不知道如何执行此操作。我以前做过,但我再也找不到宏了,所以我真的不知道我是怎么做到的。不过,我已经能够选择每个自定义布局。但是我需要遍历每个布局中的每个文本框并选择语言。我的问题是针对每个形状。我该怎么做呢?

This is what I've got so far:

这是我到目前为止所得到的:

ActiveWindow.ViewType = ppViewSlideMaster

For Each oLayout In ActivePresentation.SlideMaster.CustomLayouts
    oLayout.Select
Next   

This basically loops through each layout. But I can't figure out how to select each placeholder? How do I do this?

这基本上遍历每个布局。但我不知道如何选择每个占位符?我该怎么做呢?

Edit: Resolution is now:

编辑:分辨率现在是:

For Each oLayout In ActivePresentation.SlideMaster.CustomLayouts
    oLayout.Select
    Dim oShape As Shape
    For Each oShape In oLayout.Shapes
        oShape.Select
    Next
Next

回答by SLaks

Loop through oLayout.Shapes, or perhaps oLayout.Shapes.Placeholders.

循环oLayout.Shapes,或者也许oLayout.Shapes.Placeholders

回答by mooseman

Thanks you two. I needed a solution to updating an embedded Excel object on the master slide. This lead me to the perfect solution

谢谢两位。我需要一个解决方案来更新母版幻灯片上的嵌入式 Excel 对象。这让我找到了完美的解决方案

'loops through all shapes in slidemaster
    Dim oShape As Shape
    For Each oShape In ActivePresentation.SlideMaster.Shapes
        oShape.Select
        'checks for excel object (type=7)
                 If oShape.Type = msoEmbeddedOLEObject Then
                    oShape.OLEFormat.Activate

                    ActiveWindow.Selection.Unselect  'deactivates shape
                End If
    Next