我被难住了。请帮忙。什么 VBA 代码可用于将命令按钮从一张幻灯片复制到另一张幻灯片(以及它们背后的代码)?我想我可以处理循环,但我找不到执行实际复制的代码/行/命令。谢谢!
答案1
下面是一个 VBA 宏,用于将所有按钮从一张幻灯片复制到另一张幻灯片:
Option Explicit
Public Sub copyButtons(sourceSlide As Slide, targetSlide As Slide)
Dim shp As Shape
If sourceSlide.Name <> targetSlide.Name Then
For Each shp In sourceSlide.Shapes
If InStr(shp.Name, "Button") > 0 Then
shp.Copy
targetSlide.Shapes.Paste
End If
Next shp
End If
End Sub
Public Sub testCopyButtons()
Dim sourceSlide As Slide
Dim targetSlide As Slide
Set sourceSlide = ActivePresentation.Slides(2)
Set targetSlide = ActivePresentation.Slides(3)
Call copyButtons(sourceSlide, targetSlide)
End Sub
复制的按钮将继承原始按钮的链接和操作。