如何在 PowerPoint 中通过 VBA 切换 activeprensentation/activeslide 自定义布局中的项目?

How to toggle item in custom layout of activeprensentation/activeslide via VBA in PowerPoint?

如何切换 (set .visible = true/false) 在自定义 layout/master 布局中定义的项目 (shade)?

示例: 我的自定义布局编号 3 中有一个名为 "TEST1" 的项目 我的自定义布局中有几张幻灯片,所以我需要先获取使用的自定义布局的编号。因为 VBA 必须在所有幻灯片上 运行。 我试过了:

ActivePresentation.SlideMaster.CustomLayouts(ActiveWindow.View.Slide.SlideIndex).Shapes("TEST1").Visible = msoFalse

但这行不通...

如果要访问给定幻灯片的自定义布局,请使用:

Option Explicit

' ***********************************************************
' Purpose:  Hide & Show a shape on the slide's custom layout.
'           Works in and out of slide show mode.
'           Change the constant sShapeName as required.
' Inputs:   None.
' Outputs:  None.
' Author:   Jamie Garroch
' Company:  YOUpresent Ltd. http://youpresent.co.uk/
' ***********************************************************
Sub ToggleCustomLayoutObject()
  Const sShapeName = "TEST1"
  Dim oSld As Slide
  If SlideShowWindows.Count = 0 Then
    Set oSld = ActivePresentation.Slides(ActiveWindow.View.Slide.SlideIndex)
  Else
    Set oSld = ActivePresentation.Slides(ActivePresentation.SlideShowWindow.View.Slide.SlideIndex)
  End If
  With oSld.CustomLayout
    .Shapes(sShapeName).Visible = Not .Shapes(sShapeName).Visible
  End With
End Sub