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
ASKER CERTIFIED SOLUTION
Avatar of Rgonzo1971
Rgonzo1971

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of John Wilson
John Wilson
Flag of United Kingdom of Great Britain and Northern Ireland image

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?
Avatar of DCUnited
DCUnited
Flag of United States of America image

ASKER

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.
Avatar of John Wilson
John Wilson
Flag of United Kingdom of Great Britain and Northern Ireland image

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
Avatar of DCUnited
DCUnited
Flag of United States of America image

ASKER

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
Programming
Programming

Programming includes both the specifics of the language you’re using, like Visual Basic, .NET, Java and others, but also the best practices in user experience and interfaces and the management of projects, version control and development. Other programming topics are related to web and cloud development and system and hardware programming.

55K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo