Avatar of DCUnited
DCUnitedFlag for United States of America asked on

Insert slides from different PowerPoints into 1

Each week I have to compile a PowerPoint presentation by compiling 4 different pptx into 1.
I have used VB in Excel and Access but never in PowerPoint so I am at a loss.
What would an example code be to go out to the path of a pptx and insert at a specific slide number? 1st pptx would start on slide 2, 2nd pptx would start on slide 11 and so on.
Microsoft PowerPointProgrammingVB Script

Avatar of undefined
Last Comment
DCUnited

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Rgonzo1971

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
John Wilson

Thanks for reposting my code Rgonzo but it may not do what is required here.

Some Questions for DC

Are the PowerPoints in the same folder or can they be?
!s the insert order the same as the alpha order of files names (again could it be)?


When you say 1st PPTX starts at slide 2 and 2nd at slide 11 do you mean you want them to insert at the end of the current file or at position 2,11 no matter how long the file is?
ASKER
DCUnited

Each of the pptx will not grow in number of slides. My thought was: once all the slides have been compilled into the one, if by some chance one of the pp needs to be updated causing it to be reinserted into the main pp then it will go into the correct order and not inserted at the end.
John Wilson

Sop you mean you would want to REPLACE say slides 2-11 with updated slides?

Is it safe to assume the total length of the presentation should always be the sum of slides in the component presentations?

Something based on this might work

Sub replaceSlides()
Dim osld As Slide
Dim L As Long
Dim lngLen As Long
Dim lngStart As Long
On Error Resume Next
'delete old slides from pres1 - do this manually first time
'as tags will not exist
For L = ActivePresentation.Slides.Count To 1 Step -1
Set osld = ActivePresentation.Slides(L)
If osld.Tags("FROM") = "P1" Then osld.Delete
Next L
lngLen = 2 ' number of slides inserted - change to suit
lngStart = 1 ' insert after this slide
ActivePresentation.Slides.InsertFromFile "FullPath to pres1", lngStart
For L = lngStart + 1 To lngStart + lngLen
ActivePresentation.Slides(L).Tags.Add "FROM", "P1"
Next L

'delete old slides from pres2 - do this manually first time
For L = ActivePresentation.Slides.Count To 1 Step -1
Set osld = ActivePresentation.Slides(L)
If osld.Tags("FROM") = "P2" Then osld.Delete
Next L
lngLen = 3 ' number of slides inserted - change to suit
lngStart = 4 ' insert after this slide
ActivePresentation.Slides.InsertFromFile "FullPath to pres2", lngStart
For L = lngStart + 1 To lngStart + lngLen
ActivePresentation.Slides(L).Tags.Add "FROM", "P2"
Next L
'continue
End Sub
Your help has saved me hundreds of hours of internet surfing.
fblack61
ASKER
DCUnited

Can't seem to get it to work.
Maybe what I was wanting to do is too complex for me.
If I can just the insert slides.
Insert ppt1 into Mainppt
Then insert ppt2 into Mainppt
then insert ppt3 and so on