2017-03-16 48 views
0

我試圖將幻燈片1從外部ppt複製到當前ppt到註釋頁面中。但是,我收到此錯誤消息:複製粘貼來自另一個ppt的數據時出錯

幻燈片(未知成員):無效的請求。剪貼板是空的或 包含可能無法粘貼在這裏的數據。

從我複製的外部ppt包含數據。

VBA腳本:

Sub copySlide() 
Dim objPresentation As Presentation 

Set objPresentation = Presentations.Open("/path/slides.ppt") 

objPresentation.Slides.Item(1).Copy 
Presentations.Item(1).Slides.Paste 

objPresentation.Close 
End Sub 
+0

不會是這一行:演示.Item(1).Slides.Paste這是錯誤的?你想要將幻燈片粘貼到activePresentation中? – basslo

+0

是的我想從外部ppt複製幻燈片到當前打開的ppt中,通過它運行宏。 –

+0

@RahulDagli看到我的回答如下,讓我知道,如果它是你打算 –

回答

1

嘗試下面的代碼,我希望你的演示文稿在("/path/slides.ppt")不會引發錯誤。

我加了2個選擇,要麼將其放置在年底,或作爲第二張幻燈片 - 您可以修改Paste線容易

代碼

Sub copySlide() 

Dim MyPres   As Presentation 
Dim objPresentation As Presentation 

Set MyPres = ActivePresentation 
Set objPresentation = Presentations.Open("/path/slides.ppt") 

objPresentation.Slides(1).Copy 
'MyPres.Slides.Paste MyPres.Slides.Count + 1 ' <-- place it at the end 
MyPres.Slides.Paste 2 ' <-- place it as the second slide 

objPresentation.Close 
Set objPresentation = Nothing ' clear object 

End Sub 
+0

我想你的代碼,但我仍然得到錯誤在這條線'同樣的錯誤MyPres.Slides.Paste 2'< - 把它作爲第二張幻燈片' –

+0

@RahulDagli代碼行中有''',對嗎? 'MyPres.Slides.Paste 2'和之後的評論之間? –

+0

是的,我完全複製和粘貼你的代碼,只有我改變的路徑。 –

相關問題