您可以使用名为“ActivePresentation.Designs(x).SlideMaster.CustomLayouts”的对象来访问 SlideMaster 设计中的每个自定义布局幻灯片。(您可以在演示文稿中拥有多个设计。)
访问自定义布局幻灯片中的子对象就像处理普通幻灯片中的子对象一样。
我认为您可以尝试以下自动化代码:
Option Explicit
Option Compare Text 'Ignore Upper/Lower case
Sub UpdateCustomLayouts()
Dim DSN As Design
Dim CL As CustomLayout
Dim shp As Shape
Dim mName As String, mCode As String, mPhone As String, fName As String
'First, change following variables before running this macro
mName = "Your name"
mCode = "Your code"
mPhone = "0123456789"
fName = ActivePresentation.Name
'Loop each customlayouts
For Each DSN In ActivePresentation.Designs
For Each CL In DSN.SlideMaster.CustomLayouts
For Each shp In CL.Shapes
If shp.HasTextFrame Then
'find and update textboxes
With shp.TextFrame.TextRange
If .Text Like "CONFIG. MGR:*" Then
.Text = "CONFIG. MGR: " & mName & ", " & mCode & ", " & mPhone
ElseIf .Text Like "FILE NAME:*" Then
.Text = "FILE NAME: " & fName
End If
End With
End If
Next shp
Next CL
Next DSN
End Sub
正如我所提到的,在运行之前首先更改变量,如“mName、mCode、mPhone、fName”。