我有2套ppt。第一组是一个模板,其中包含幻灯片1上的占位符形状。另一个ppt包含幻灯片1上的图像,我想复制并用第一个ppt中的占位符替换它。
当我运行下面提到的以下代码时,我收到此错误消息
编译错误:找不到方法或数据成员
代码:
Sub copySlide()
Dim objPresentation As Presentation
Set objPresentation = Presentations.Open("/path/slides.ppt")
objPresentation.Slides.Item(1).Shapes("image_1").Copy
Presentations.Item(1).Slides.Shapes("image_placeholder_1").Paste
objPresentation.Close
End Sub
答案 0 :(得分:0)
您只需在粘贴部分指定幻灯片,然后调整图片的位置:
Sub copySlide()
Dim objPresentation As Presentation
Set objPresentation = Presentations.Open("/path/slides.ppt")
Dim PPShape As Object
objPresentation.Slides.Item(1).Shapes("image_1").Copy
Set PPShape = Presentations.Item(1).Slides(1).Shapes.Paste
With PPShape
.Height = 100
'Place from bottom using : PPPres.PageSetup.SlideHeigth - .Height
.Top = PPPres.PageSetup.SlideHeigth - .Height - 10
.Width = 100
'Place from right using : PPPres.PageSetup.SlideWidth - .Width
.Left = PPPres.PageSetup.SlideWidth - .Width - 10
End With
objPresentation.Close
End Sub