Chris Macro
06-09-2014, 07:19 AM
I have created a macro to copy over only the user selected slides into a brand new PowerPoint presentation. The problem I have noticed is that when slides are selected in consecutive order (ie 4-9), the macro will paste the slides in the correct order. However when the selection is not in consecutive order ( ie 4,5,8,9), it will paste the slides in reverse order. Any thoughts on why this is happening or how I can fix this?
Code:
Sub Copy_Selection_To_New_PPT()
'PURPOSE: Copies selected slides and pastes them into a brand new presentation file
Dim NewPPT As Presentation
Dim Selected_slds As SlideRange
Dim Old_sld As Slide
Dim New_sld As Slide
Dim x As Long
'Set variable equal to only selected slides in Active Presentation
Set Selected_slds = ActiveWindow.Selection.SlideRange
'Create a brand new PowerPoint presentation
Set NewPPT = Presentations.Add
'Loop through slides in SlideRange
For x = 1 To Selected_slds.Count
'Set variable to a specific slide
Set Old_sld = Selected_slds(x)
'Copy Old Slide
yy = Old_sld.SlideIndex
Old_sld.Copy
'Paste Slide in new PowerPoint
NewPPT.Slides.Paste
Set New_sld = Application.ActiveWindow.View.Slide
'Bring over slides design
New_sld.Design = Old_sld.Design
'Bring over slides custom color formatting
New_sld.ColorScheme = Old_sld.ColorScheme
'Bring over whether or not slide follows Master Slide Layout (True/False)
New_sld.FollowMasterBackground = Old_sld.FollowMasterBackground
Next x
End Sub
Code:
Sub Copy_Selection_To_New_PPT()
'PURPOSE: Copies selected slides and pastes them into a brand new presentation file
Dim NewPPT As Presentation
Dim Selected_slds As SlideRange
Dim Old_sld As Slide
Dim New_sld As Slide
Dim x As Long
'Set variable equal to only selected slides in Active Presentation
Set Selected_slds = ActiveWindow.Selection.SlideRange
'Create a brand new PowerPoint presentation
Set NewPPT = Presentations.Add
'Loop through slides in SlideRange
For x = 1 To Selected_slds.Count
'Set variable to a specific slide
Set Old_sld = Selected_slds(x)
'Copy Old Slide
yy = Old_sld.SlideIndex
Old_sld.Copy
'Paste Slide in new PowerPoint
NewPPT.Slides.Paste
Set New_sld = Application.ActiveWindow.View.Slide
'Bring over slides design
New_sld.Design = Old_sld.Design
'Bring over slides custom color formatting
New_sld.ColorScheme = Old_sld.ColorScheme
'Bring over whether or not slide follows Master Slide Layout (True/False)
New_sld.FollowMasterBackground = Old_sld.FollowMasterBackground
Next x
End Sub