在单个演示文稿中访问多个主题的母版幻灯片

Accessing Master Slides for Multiple Themes in a Single Presentation

我一直在开发一个 VBA 宏,它可以自动在母版幻灯片上为多个指定人员创建水印,然后自动将其保存为单独的 PDF。所有这一切现在都运作良好。但是,我可能需要为某些演示文稿加水印,将多个主题应用于不同的幻灯片。 (例如,上半部分使用主题 1,下半部分使用主题 2)每个主题都有单独的母版幻灯片。当我使用 ActivePresentation.SlideMaster 时,这只会影响幻灯片母版视图中最上面的母版幻灯片。我将如何访问其他主题的母版幻灯片?

编辑:这是我的代码。 xlVariables 来自 Excel 文件。水印线是指最靠后的文本框。我搜索了一种访问多张母版幻灯片的方法,但找不到任何内容。

xlName = Range("A" & CStr(count))
xlCompany = Range("B" & CStr(count))
xlDate = Range("C" & CStr(count))
xlMail = Range("D" & CStr(count))

'Create the watermark
ActivePresentation.SlideMaster.Shapes(1).TextFrame.TextRange.text = "Confidential - Do Not Share" & vbNewLine & "Issued to " _
& xlName & vbNewLine & "on " & xlDate & vbNewLine & xlCompany & " - Internal Use Only"

这里有一些示例代码,可以对演示文稿中的每个母版(oDes.SlideMaster 代码)和布局 (oLay) 执行一些操作(您定义)。

修改 DoSomethingWithShapeContainer 以对每个 master/layout.

执行您需要执行的任何操作
Sub AllMastersAndLayouts()

Dim oLay As CustomLayout
Dim oDes As Design

With ActivePresentation

For Each oDes In .Designs
    Call DoSomethingWithShapeContainer(oDes.SlideMaster)
    For Each oLay In oDes.SlideMaster.CustomLayouts
        Call DoSomethingWithShapeContainer(oLay)
    Next
Next

End With


End Sub

Sub DoSomethingWithShapeContainer(oShapeContainer As Object)
    With oShapeContainer.Shapes.AddTextbox(msoTextOrientationHorizontal, 20, 20, 200, 50)
        .TextFrame.TextRange.Text = "I did something here"
    End With
End Sub