2017-03-16 46 views
1

我有2套ppt。第一组是包含幻灯片1上的占位符形状的模板。其他ppt包含幻灯片1上的图像,我希望将其复制并替换为第一个ppt中的占位符。如何将图片从一个ppt复制粘贴到另一个ppt

当我运行下面的代码中提到下面我得到这个错误味精

Compiled error: Method or data member not found

代码:

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

你只需要指定粘贴部分幻灯片,然后调整放置图片:

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 
相关问题