Skip to content

Instantly share code, notes, and snippets.

@shaunthegeek
Last active July 1, 2023 02:01
Show Gist options
  • Select an option

  • Save shaunthegeek/aea6a1d4445f44d23927b60edc9cf04c to your computer and use it in GitHub Desktop.

Select an option

Save shaunthegeek/aea6a1d4445f44d23927b60edc9cf04c to your computer and use it in GitHub Desktop.
Merge two PPT files page by page in order
Sub MergeTwoPPTX()
Dim strSlidesPath1 As String
Dim strSlidesPath2 As String
Dim pageCount As Long
Dim oTarget As Presentation
strSlidesPath1 = "/Users/sink/Downloads/XYL-7.pptx"
strSlidesPath2 = "/Users/sink/Downloads/002-XYL-7.pptx"
' Get number of slides
Set tmp = Presentations.Open(strSlidesPath2)
pageCount = tmp.Slides.Count
tmp.Close
' Create an empty presentation
Set oTarget = Application.Presentations.Add(WithWindow:=True)
For i = 1 To pageCount
' InsertFromFile _FileName_, _Index_, _SlideStart_, _SlideEnd_
oTarget.Slides.InsertFromFile strSlidesPath1, oTarget.Slides.Count, i, i
oTarget.Slides.InsertFromFile strSlidesPath2, oTarget.Slides.Count, i, i
If i Mod 50 = 0 Then DoEvents
Next i
End Sub
@shaunthegeek
Copy link
Author

notice:

  1. don't use space in filename
  2. don't use ppt but pptx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment