我正在尝试使用VBA从Excel向PowerPoint幻灯片添加水印,但不知道从哪里开始。我已经在Google上搜索,却一无所获。 Stackoverflow上有一个问题有所帮助,但我无法理解。我想知道是否有人可以将我引至某个地方或将我指向正确的方向?同样,我只想在Master View中的一张幻灯片上添加水印。谢谢!
答案 0 :(得分:1)
要在“母版视图”中更改幻灯片,可以使用CustomLayouts
集合。
请注意,您必须按索引CustomLayout
来引用特定的Name
,而不要像this question所指出的那样引用其Presentation
。
此示例代码
Picture 1
Shapes
并将其粘贴到第一个CustomLayout
的{{1}}集合中,对我来说,这是“标题幻灯片版式”。 我假设您可以在此处修改其大小/位置或进行其他所需的更改。
Sub AddWatermark()
Dim wmark As Shape: Set wmark = ThisWorkbook.Sheets("Sheet1").Shapes("Picture 1")
Dim PPT As PowerPoint.Application
Dim pres As PowerPoint.Presentation
On Error Resume Next
Set PPT = GetObject(, "PowerPoint.Application")
On Error GoTo 0
If PPT Is Nothing Then
Set PPT = New PowerPoint.Application
End If
PPT.Visible = True
Set pres = PPT.Presentations.Add
wmark.Copy
pres.SlideMaster.CustomLayouts(1).Shapes.Paste
End Sub
我的原始水印
标题幻灯片布局显示应用的水印