I'm using this code to insert slides from another presentation easily. It works fine BUT I've noticed the copied slides come across in random order. i.e. not the same order they are in the PowerPoint file. How can I fix this please?
Dim i As Integer
Dim PPDD As String
Dim X As Long
Dim Y As Long
Dim Z As Long
With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = False
.Filters.Add "PowerPoint Files", "*.pptx; *.ppt; *.pptm; *.ppsm", 1
.Show
On Error Resume Next
PPDD = .SelectedItems.Item(1)
End With
X = InputBox("Please enter which position (slide number) you'd like the selected PowerPoint file to be inserted", "slide number", "1")
Y = InputBox("Please enter the number of the first slide you want to copy", "slide number", "1")
Z = InputBox("Please enter the number of the last slide you want to copy", "slide number", "1")
Set objPresentation = Presentations.Open(PPDD, WithWindow:=msoFalse)
For i = Y To Z
objPresentation.Slides.Item(i).Copy
Presentations.Item(1).Slides.Paste X
Presentations.Item(1).Slides.Item(Presentations.Item(1).Slides.count).Design = _
objPresentation.Slides.Item(i).Design
Next i
objPresentation.Close