我有兴趣将以下VBA代码应用于PowerPoint演示文稿中的所有幻灯片。下面的代码将表格的大小调整为所需的确切规格。您对我如何在整个演示过程中应用它有任何建议吗?提前致谢。
Sub ResizeAlign()
With ActiveWindow.Selection.ShapeRange
.Height = 216
.Width = 864
.Left = 48
.Top = 198
ActiveWindow.Selection.ShapeRange.ZOrder msoSendToBack
End With
End Sub
答案 0 :(得分:1)
下面的宏将在活动演示文稿中的每个幻灯片中循环。然后,对于每张幻灯片,它将循环遍历幻灯片中的每个形状,直到找到表格为止,然后对表格进行格式化。
Option Explicit
Public Sub ResizeAlignPresentation()
Dim currentSlide As Slide
For Each currentSlide In ActivePresentation.Slides
ResizeAlignSlide currentSlide
Next
End Sub
Private Sub ResizeAlignSlide(ByVal target As Slide)
Dim currentShape As Shape
For Each currentShape In target.Shapes
If currentShape.Type = msoTable Then
ResizeAlignTable currentShape
Exit For
End If
Next
End Sub
Private Sub ResizeAlignTable(ByVal table As Shape)
With table
Debug.Assert .Type = msoTable 'if code breaks here, we have a bug!
.Height = 216
.Width = 864
.Left = 48
.Top = 198
.ZOrder msoSendToBack
End With
End Sub
答案 1 :(得分:0)
我用我创建的此代码(需要)增加了最后一个答案。我需要遍历所有SlideMaster,所有幻灯片,所有文本框,并将它们放在顶部。因此它们将始终在图片等的前面。
Sub SetInFront()
Dim m, s, t, ma, sl, te
Set ma = ActivePresentation.Designs
For Each m In ma
Set sl = m.SlideMaster.CustomLayouts
For Each s In sl
Set te = s.Shapes
For Each t In te
If t.HasTextFrame Then
t.ZOrder 0
End If
Next t
Next s
Next m
End Sub