如何通过PowerPoint中的VBA在ActivePreSentation/activeslide的自定义布局中切换项目?
如何切换(如何通过PowerPoint中的VBA在ActivePreSentation/activeslide的自定义布局中切换项目?,vba,powerpoint,Vba,Powerpoint,如何切换(set.visible=true/false)自定义布局/主布局中定义的项目(shade) 例如: 我在自定义布局3中有一个名为“TEST1”的项 我的自定义布局中有几张幻灯片,因此我需要先获得使用的自定义布局的编号。。因为VBA必须在所有幻灯片上运行。。 我试过: 但这不起作用…如果要访问给定幻灯片的自定义布局,请使用以下选项: Option Explicit ' ***********************************************************
set.visible=true/false
)自定义布局/主布局中定义的项目(shade
)
例如:
我在自定义布局3中有一个名为“TEST1”的项
我的自定义布局中有几张幻灯片,因此我需要先获得使用的自定义布局的编号。。因为VBA必须在所有幻灯片上运行。。
我试过:
但这不起作用…如果要访问给定幻灯片的自定义布局,请使用以下选项:
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
很抱歉,这不起作用-如果我单击使用上面代码的按钮,“TEST1”形状仍然可见。这适用于:ActivePresentation.Designs(1)、SlideMaster.CustomLayouts(6)、Shapes(“TEST1”).Visible=msoFalseAh。按钮等于幻灯片放映模式!更新代码以支持普通视图和幻灯片放映视图。
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