[英]Copy one slide to multiple presentation
I have task to copy one slide to multiple ppt presentations. 我的任务是将一张幻灯片复制到多个ppt演示文稿中。 All ppts are in same folder. 所有ppts都位于同一文件夹中。 I don't have an idea how to start. 我不知道如何开始。 So far I have change some simple stuff with VBA as changing font, title etc. Anybody can help me? 到目前为止,我已经使用VBA更改了一些简单的内容,例如更改了字体,标题等。有人可以帮助我吗? Thanks in advance 提前致谢
I found this VBA code that may help you get started. 我发现此VBA代码可能会帮助您入门。 This will copy all of the slides from the first presentation to a second presentation using a loop. 这将使用循环将所有幻灯片从第一个演示文稿复制到第二个演示文稿。 You can modify the code to copy a single slide and then past into multiple presentations with the loop. 您可以修改代码以复制一张幻灯片,然后使用循环将其复制到多个演示文稿中。
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
For example, if you open the target PPTX presentation and run the following VBA macro, it will copy the first slide out of the 2.pptx presentation file and paste it into the current target PPTX. 例如,如果您打开目标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
Use the InsertSlideFromFile method which takes this form: 使用采用以下形式的InsertSlideFromFile方法:
.InsertFromFile(FileName, Index, SlideStart, SlideEnd)
Example. 例。 To copy slides 3 to 4 from test.pptx and paste them to the end of your currently open presentation (the ActivePresentation): 要从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
If all files are on the same path as the open presentation, you can automate the path by starting with this: 如果所有文件都与打开的演示文稿位于相同的路径上,则可以从以下位置开始自动执行路径:
Dim myPath as String
MyPath = ActivePresentation.Path
More info on the InsertSlideFromFile method here: 有关InsertSlideFromFile方法的更多信息,请参见:
https://msdn.microsoft.com/en-us/library/office/ff746047.aspx?f=255&MSPPError=-2147217396 https://msdn.microsoft.com/zh-cn/library/office/ff746047.aspx?f=255&MSPPError=-2147217396
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.