Ваша проблема заключалась в том, что он вводил их в обратном порядке. Когда вы звоните Presentations.Item(1).Slides.Paste X
, он сохраняет вставку в эту позицию X. Что вам действительно нужно, так это постепенное смещение этого исходного индекса при вставке.
Я изменил обработку переменных, но по сути это то же самое.
Option Explicit
Sub CopySlide()
Dim pptStart As Presentation
Set pptStart = ActivePresentation
With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = False
.Filters.Add "PowerPoint Files", "*.pptx; *.ppt; *.pptm; *.ppsm", 1
.Show
On Error Resume Next
Dim PPDD As String
PPDD = .SelectedItems.Item(1)
On Error GoTo 0
End With
If Len(PPDD) = 0 Then
MsgBox "File not chosen. Closing."
Exit Sub
End If
Dim pptOpened As Presentation
Set pptOpened = Presentations.Open(PPDD, WithWindow:=msoFalse)
Dim indexInsertAt As Long
indexInsertAt = InputBox("Please enter which position (slide number) you'd like the selected PowerPoint file to be inserted", "slide number", "1")
Dim indexCopyFirst As Long
indexCopyFirst = InputBox("Please enter the number of the first slide you want to copy", "slide number", "1")
Dim indexCopyLast As Long
indexCopyLast = InputBox("Please enter the number of the last slide you want to copy", "slide number", "1")
Dim offset As Long
Dim i As Long
For i = indexCopyFirst To indexCopyLast
pptOpened.Slides.Item(i).Copy
pptStart.Slides.Paste (indexInsertAt + offset)
pptStart.Slides.Item(indexInsertAt + offset).Design = _
pptOpened.Slides.Item(i).Design
offset = offset + 1
Next i
pptOpened.Close
End Sub