簡體   English   中英

將一張幻燈片復制到多個演示文稿

[英]Copy one slide to multiple presentation

我的任務是將一張幻燈片復制到多個ppt演示文稿中。 所有ppts都位於同一文件夾中。 我不知道如何開始。 到目前為止,我已經使用VBA更改了一些簡單的內容,例如更改了字體,標題等。有人可以幫助我嗎? 提前致謝

我發現此VBA代碼可能會幫助您入門。 這將使用循環將所有幻燈片從第一個演示文稿復制到第二個演示文稿。 您可以修改代碼以復制一張幻燈片,然后使用循環將其復制到多個演示文稿中。

Sub main()
Dim objPresentation As Presentation
Dim i As Integer

'open the target presentation
Set objPresentation = Presentations.Open("C:\2.pptx")
For i = 1 To objPresentation.Slides.Count
objPresentation.Slides.Item(i).Copy
Presentations.Item(1).Slides.Paste
Next i
objPresentation.Close
End Sub

例如,如果您打開目標PPTX演示文稿並運行以下VBA宏,它將從2.pptx演示文稿文件中復制第一張幻燈片並將其粘貼到當前的目標PPTX中。

Sub copySlide()
Dim objPresentation As Presentation

'open the target presentation
'use path with the file if it is in a different location ("c:\2.pptx")
Set objPresentation = Presentations.Open("2.pptx")

'copy slide 1 from 2.pptx presentation
'change the item number in order to target a different slide
objPresentation.Slides.Item(1).Copy

'paste the slide in target
Presentations.Item(1).Slides.Paste

objPresentation.Close
End Sub

使用采用以下形式的InsertSlideFromFile方法:

.InsertFromFile(FileName, Index, SlideStart, SlideEnd)

例。 要從test.pptx復制幻燈片3到4,並將其粘貼到當前打開的演示文稿(ActivePresentation)的末尾,請執行以下操作:

' VBA macro to insert slide(s) from file
' Written by Jamie Garroch of http://youpresent.co.uk/
Sub InsertSlides()
  With ActivePresentation.Slides
    .InsertFromFile "test.pptx", .Count, 3, 4
  End With
End Sub

如果所有文件都與打開的演示文稿位於相同的路徑上,則可以從以下位置開始自動執行路徑:

Dim myPath as String
MyPath = ActivePresentation.Path

有關InsertSlideFromFile方法的更多信息,請參見:

https://msdn.microsoft.com/zh-cn/library/office/ff746047.aspx?f=255&MSPPError=-2147217396

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM