[英]How to apply VBA code to all Powerpoint slides
I am interested in applying the following VBA code to all slides in my powerpoint presentation.我有兴趣将以下 VBA 代码应用于我的 powerpoint 演示文稿中的所有幻灯片。 The code below resizes my table to the exact specifications I need.
下面的代码将我的表格调整为我需要的确切规格。 Do you have any advice on how to make this apply throughout my presentation?
你对如何在我的演讲中应用这一点有什么建议吗? Thanks in advance.
提前致谢。
Sub ResizeAlign()
With ActiveWindow.Selection.ShapeRange
.Height = 216
.Width = 864
.Left = 48
.Top = 198
ActiveWindow.Selection.ShapeRange.ZOrder msoSendToBack
End With
End Sub
The following macro will loop through each slide within the active presentation.以下宏将循环播放活动演示文稿中的每张幻灯片。 Then, for each slide, it will loop through each shape within the slide until it finds a table, and then it formats the table.
然后,对于每张幻灯片,它会遍历幻灯片中的每个形状,直到找到一个表格,然后格式化表格。
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
I have upped the last answer with this code I created (in need).我用我创建的这个代码(需要)提高了最后一个答案。 I needed to run through all SlideMasters, all slides, all textboxes and put them on top.
我需要浏览所有 SlideMaster、所有幻灯片、所有文本框并将它们放在最上面。 So they will always be in front of pictures etc.
所以他们将永远在图片等面前。
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.