从 Excel 向 PowerPoint 幻灯片添加水印
Add Watermark to PowerPoint Slide from Excel
我正在尝试为来自 Excel 和 VBA 的 PowerPoint 幻灯片添加水印,但不知道从哪里开始。我在 Google 上搜索过,但一无所获。 Whosebug 上有一个问题有点帮助,但我无法理解。我想知道是否有人可以将我引荐到某个地方或指出正确的方向?同样,我只想在母版视图中的其中一张幻灯片中添加水印。谢谢!
要在母版视图中更改幻灯片,您可以使用 CustomLayouts
collection。
请注意,您必须通过索引引用特定的 CustomLayout
,而不是 Name
,正如 this question 指出的那样。
这个示例代码
- 创建或获取 PowerPoint 实例
- 创建一个新的
Presentation
- 复制
Picture 1
并将其粘贴到第一个 CustomLayout
的 Shapes
collection 中,这对我来说是标题幻灯片布局。
我假设您可以从这里修改它 size/position 或进行任何其他所需的更改。
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
我的原创水印
显示已应用水印的标题幻灯片布局
我正在尝试为来自 Excel 和 VBA 的 PowerPoint 幻灯片添加水印,但不知道从哪里开始。我在 Google 上搜索过,但一无所获。 Whosebug 上有一个问题有点帮助,但我无法理解。我想知道是否有人可以将我引荐到某个地方或指出正确的方向?同样,我只想在母版视图中的其中一张幻灯片中添加水印。谢谢!
要在母版视图中更改幻灯片,您可以使用 CustomLayouts
collection。
请注意,您必须通过索引引用特定的 CustomLayout
,而不是 Name
,正如 this question 指出的那样。
这个示例代码
- 创建或获取 PowerPoint 实例
- 创建一个新的
Presentation
- 复制
Picture 1
并将其粘贴到第一个CustomLayout
的Shapes
collection 中,这对我来说是标题幻灯片布局。
我假设您可以从这里修改它 size/position 或进行任何其他所需的更改。
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
我的原创水印
显示已应用水印的标题幻灯片布局