PDA

View Full Version : [SOLVED:] Inserting Slides Behind Current Slide rather than at the end



RayKay
08-13-2019, 12:35 AM
Hi John

I have this code that you fantastically created, and I'm sure people will find useful, but I have a question:

It inserts slides at the end of the current document, can it insert selected slides (files) to after the slide you're currently viewing?

I.e. say you have file Z open, with 7 slides and you are viewing slide 3, this tool inserts them after slide 3 rather than at the end?

Thank you :2jump::2jump:




Sub ViewSlides()
Dim L As LongDim opres As PresentationDim FD As FileDialogSet opres = ActivePresentationSet FD = Application.FileDialog(msoFileDialogOpen)With FD.InitialFileName = "C:\".ButtonName = "Merge".AllowMultiSelect = True.Filters.Clear.Filters.Add "Presentations", "*.pptx"If .Show = True ThenIf .SelectedItems.Count > 0 ThenFor L = 1 To .SelectedItems.CountCall opres.Slides.InsertFromFile(.SelectedItems(L), opres.Slides.Count)Next LEnd IfEnd IfEnd With
Exit Sub
End Sub

John Wilson
08-13-2019, 12:46 AM
See if this works.


Sub ViewSlides()
Dim L As Long
Dim opres As Presentation
Dim FD As FileDialog
Dim lngPos As Long
Set opres = ActivePresentation
'get current position
lngPos = ActiveWindow.Selection.SlideRange(1).SlideIndex
Set FD = Application.FileDialog(msoFileDialogOpen)
With FD
.InitialFileName = "C:\"
.ButtonName = "Merge"
.AllowMultiSelect = True
.Filters.Clear
.Filters.Add "Presentations", "*.pptx"
If .Show = True Then
If .SelectedItems.Count > 0 Then
For L = 1 To .SelectedItems.Count
Call opres.Slides.InsertFromFile(.SelectedItems(L), lngPos)
Next L
End If
End If
End With
Exit Sub
End Sub

RayKay
08-14-2019, 01:09 AM
PERFECT CODE - THANK YOU!!