Log in

View Full Version : Insert powerpoint slide



Jack.Conroy
01-04-2016, 12:21 AM
Hi,
I have a simple one which is frustrating me. I am trying to insert one slide from another presentation (file) into the current presentation but after the active slide I am working on. I can only seem to insert it after slide 1 on the active presentation. Any ideas how to change this to be after the active slide?


Sub InsertObject()
ActivePresentation.Slides.InsertFromFile "C:\Users\HDCOLW\Desktop\New Format\Rounded Text Box.pptx", 1, 1, 1
End Sub

Thanks,
Jack

Bob Phillips
01-04-2016, 01:37 AM
You need to get the index number of active slide, and use that rather than the first 1 in the InsertFile method.

John Wilson
01-04-2016, 01:48 AM
What xld said. This should get you started


Sub InsertObject()
Dim sldIndx As Long
On Error Resume Next
sldIndx = ActiveWindow.Selection.SlideRange(1).SlideIndex
If Not sldIndx = 0 Then
ActivePresentation.Slides.InsertFromFile FileName:="C:\Users\HDCOLW\Desktop\New Format\Rounded Text Box.pptx", _
Index:=sldIndx + 1, _
SlideStart:=1, _
SlideEnd:=1
End If
End Sub