Last active
July 1, 2023 02:01
-
-
Save shaunthegeek/aea6a1d4445f44d23927b60edc9cf04c to your computer and use it in GitHub Desktop.
Merge two PPT files page by page in order
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
notice: