如何 select 布局中的特定占位符 - 幻灯片母版
How to select specific placeholder in Layout - Slide Master
我正在尝试编写一个宏来调整布局中占位符的大小,但我不知道如何将它们指示给 VBA。我尝试了几种方法,使用下面的代码我得到了 Method or data member not found。我还尝试添加两个变量(SM As Design 和 CL AS CustomLayout),然后使用“SlideMaster.CustomLayouts(4).Shapes.Placeholders("Content Placeholder 2").Name”指向 CL(如 ),但随后我在设置 MasterPlaceHolder 的行中收到 Object Required 错误。
有人可以指点一下吗?
Sub PlaceHolderResizer()
Dim LeftLimit As Single
Dim TopLimit As Single
Dim RightLimit As Single
Dim BottomLimit As Single
Dim DrawingAreaWidth As Single
Dim DrawingAreaHeight As Single
Dim MasterPlaceholder As Shape
Dim PlcHldr As Shape
Dim HorizontalDistance As Single
Dim VerticalDistance As Single
HorizontalDistance = 360
VerticalDistance = 144
Set MasterPlaceholder = SlideMaster.CustomLayouts.Shapes.Placeholders.Name("Content Placeholder 2")
LeftLimit = MasterPlaceholder.Left
TopLimit = MasterPlaceholder.Top
RightLimit = MasterPlaceholder.Left - MasterPlcHldr.Width
BottomLimit = MasterPlaceholder.Top - MasterPlcHldr.Height
DrawingAreaWidth = MasterPlaceholder.Width
DrawingAreaHeight = MasterPlaceholder.Height
With ActivePresentation.Designs(1).SlideMaster.CustomLayouts(4)
ActivePresentation.Designs(1).Shapes.Placeholders.FindByName("Content Placeholder 2").Select 'here I get the error
With Selection
.Left = LeftLimit
.Width = (DrawingAreaWidth / 2) - HorizontalDistance
End With
End With
End Sub
我正在回答您post提出的问题。如果它回答了您的问题,请给它一个赞。我回答之后,你会有其他问题。请 post 那些在新线程中的人。 Can I ask only one question per post?
您是否打开了 VB 编辑器的 Intellisense(工具>选项>编辑器>自动语法检查)?这会突出显示您代码中的一些错误。
将以 With ActivePresentation 开头的部分替换为以下代码:
For Each oShape In ActivePresentation.Designs(1).SlideMaster.CustomLayouts(4).Shapes
If oShape.Name = "Content Placeholder 2" Then
oShape.Left = LeftLimit
oShape.Width = (DrawingAreaWidth / 2) - HorizontalDistance
End If
Next oShape
对于您的后续问题,请定义 MasterPlaceholder 应该引用的内容。幻灯片母版上的占位符?您要修改的占位符?从您现有的代码中不清楚。
我正在尝试编写一个宏来调整布局中占位符的大小,但我不知道如何将它们指示给 VBA。我尝试了几种方法,使用下面的代码我得到了 Method or data member not found。我还尝试添加两个变量(SM As Design 和 CL AS CustomLayout),然后使用“SlideMaster.CustomLayouts(4).Shapes.Placeholders("Content Placeholder 2").Name”指向 CL(如
有人可以指点一下吗?
Sub PlaceHolderResizer()
Dim LeftLimit As Single
Dim TopLimit As Single
Dim RightLimit As Single
Dim BottomLimit As Single
Dim DrawingAreaWidth As Single
Dim DrawingAreaHeight As Single
Dim MasterPlaceholder As Shape
Dim PlcHldr As Shape
Dim HorizontalDistance As Single
Dim VerticalDistance As Single
HorizontalDistance = 360
VerticalDistance = 144
Set MasterPlaceholder = SlideMaster.CustomLayouts.Shapes.Placeholders.Name("Content Placeholder 2")
LeftLimit = MasterPlaceholder.Left
TopLimit = MasterPlaceholder.Top
RightLimit = MasterPlaceholder.Left - MasterPlcHldr.Width
BottomLimit = MasterPlaceholder.Top - MasterPlcHldr.Height
DrawingAreaWidth = MasterPlaceholder.Width
DrawingAreaHeight = MasterPlaceholder.Height
With ActivePresentation.Designs(1).SlideMaster.CustomLayouts(4)
ActivePresentation.Designs(1).Shapes.Placeholders.FindByName("Content Placeholder 2").Select 'here I get the error
With Selection
.Left = LeftLimit
.Width = (DrawingAreaWidth / 2) - HorizontalDistance
End With
End With
End Sub
我正在回答您post提出的问题。如果它回答了您的问题,请给它一个赞。我回答之后,你会有其他问题。请 post 那些在新线程中的人。 Can I ask only one question per post?
您是否打开了 VB 编辑器的 Intellisense(工具>选项>编辑器>自动语法检查)?这会突出显示您代码中的一些错误。
将以 With ActivePresentation 开头的部分替换为以下代码:
For Each oShape In ActivePresentation.Designs(1).SlideMaster.CustomLayouts(4).Shapes
If oShape.Name = "Content Placeholder 2" Then
oShape.Left = LeftLimit
oShape.Width = (DrawingAreaWidth / 2) - HorizontalDistance
End If
Next oShape
对于您的后续问题,请定义 MasterPlaceholder 应该引用的内容。幻灯片母版上的占位符?您要修改的占位符?从您现有的代码中不清楚。