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.
DCUnitedAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rgonzo1971Commented:
HI,

pls refer to http://www.vbaexpress.com/forum/showthread.php?14663-Simple-Macro-to-import-slides-from-a-file

Sub Combine_fromFolder() 
    Dim strFPath As String 
    Dim strSpec As String 
    Dim strFileName As String 
    Dim oTarget As Presentation 
    Set oTarget = Application.Presentations.Add(WithWindow:=True) 
    strFPath = "C:\Users\John\Desktop\Test\" ' Edit this
    strSpec = "*.PPTX" 'to include PPT etc use "*.PP*"
    strFileName = Dir$(strFPath & strSpec) 
    While strFileName <> "" 
        oTarget.Slides.InsertFromFile strFileName, oTarget.Slides.Count, 1, 1 
        strFileName = Dir() 
    Wend 
End Sub

Open in new window

Regards
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JSRWilsonCommented:
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?
0
DCUnitedAuthor Commented:
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.
0
JSRWilsonCommented:
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
0
DCUnitedAuthor Commented:
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
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft PowerPoint

From novice to tech pro — start learning today.