select 部分幻灯片 VBA
select part of the slide in powerpoint VBA
有没有办法通过给出要 select 编辑的区域的坐标,从 VBA 中 select 幻灯片的特定区域。 EG 我想 select 一个位置为 top=100,left=100,hight=10 和 width=10 的区域,这个区域包括 3 个文本框,我想在后面以某种方式操作它们,比如左对齐所有 3 个他们。
特别是,我有很多幻灯片都带有这 3 个盒子,还有一些其他盒子,其中 3 个盒子的位置从一张幻灯片到另一张幻灯片变化 +/- 0.3 厘米,现在我希望它们具有所有幻灯片上的相同位置。问题是我其中一些是空框,所以我不知道如何搜索它们然后将它们包含在 selection 中,因为它们在所有幻灯片上都没有相同的形状索引.因此我想如果有 select 幻灯片特定区域的代码 - 这几乎可以解决我的问题...
谢谢!!!
FindShapesInSlides
代码将 select 幻灯片中任何幻灯片中匹配指定边界(基于顶部、左侧、高度、宽度)的所有形状(文本框等)。
然后您可以向 selected 项目添加您想要的任何操作(例如对齐它们或其他)。
Select 指定边界内的所有形状(顶部、左侧、高度、宽度)
Sub FindShapesInSlides(pTop As Single, pLeft As Single, pHeight As Single, pWidth As Single)
Dim slideShapes As Shapes
Dim slideShape As Shape
'Loop through each slide in the presentation
For i = 1 To ActivePresentation.Slides.Count
'Get shapes for the slide
Set slideShapes = ActivePresentation.Slides(i).Shapes
'Remove any existing selection
ActiveWindow.Selection.Unselect
'Loop through the shapes
For Each slideShape In slideShapes
'Check if shape is within the specified boundary
If ((slideShape.top >= pTop And slideShape.top <= (pTop + pHeight)) _
And (slideShape.left >= pLeft And slideShape.left <= (pLeft + pWidth))) Then
'Add the shape to the current selection
slideShape.Select (msoFalse)
End If
Next slideShape
Next i
End Sub
测试select离子
Sub Test()
FindShapesInSlides pTop:=50, pLeft:=50, pHeight:=100, pWidth:=50
End Sub
有没有办法通过给出要 select 编辑的区域的坐标,从 VBA 中 select 幻灯片的特定区域。 EG 我想 select 一个位置为 top=100,left=100,hight=10 和 width=10 的区域,这个区域包括 3 个文本框,我想在后面以某种方式操作它们,比如左对齐所有 3 个他们。
特别是,我有很多幻灯片都带有这 3 个盒子,还有一些其他盒子,其中 3 个盒子的位置从一张幻灯片到另一张幻灯片变化 +/- 0.3 厘米,现在我希望它们具有所有幻灯片上的相同位置。问题是我其中一些是空框,所以我不知道如何搜索它们然后将它们包含在 selection 中,因为它们在所有幻灯片上都没有相同的形状索引.因此我想如果有 select 幻灯片特定区域的代码 - 这几乎可以解决我的问题...
谢谢!!!
FindShapesInSlides
代码将 select 幻灯片中任何幻灯片中匹配指定边界(基于顶部、左侧、高度、宽度)的所有形状(文本框等)。
然后您可以向 selected 项目添加您想要的任何操作(例如对齐它们或其他)。
Select 指定边界内的所有形状(顶部、左侧、高度、宽度)
Sub FindShapesInSlides(pTop As Single, pLeft As Single, pHeight As Single, pWidth As Single)
Dim slideShapes As Shapes
Dim slideShape As Shape
'Loop through each slide in the presentation
For i = 1 To ActivePresentation.Slides.Count
'Get shapes for the slide
Set slideShapes = ActivePresentation.Slides(i).Shapes
'Remove any existing selection
ActiveWindow.Selection.Unselect
'Loop through the shapes
For Each slideShape In slideShapes
'Check if shape is within the specified boundary
If ((slideShape.top >= pTop And slideShape.top <= (pTop + pHeight)) _
And (slideShape.left >= pLeft And slideShape.left <= (pLeft + pWidth))) Then
'Add the shape to the current selection
slideShape.Select (msoFalse)
End If
Next slideShape
Next i
End Sub
测试select离子
Sub Test()
FindShapesInSlides pTop:=50, pLeft:=50, pHeight:=100, pWidth:=50
End Sub