PDA

View Full Version : Solved: Add presentation to current with slide index



twnty2
08-01-2011, 11:27 PM
Hi,

i currently use the following macro to add slides to my presentation from other presentations

Sub FI_EconomicUpdate()

If ActiveWindow.Selection.Type = ppSelectionNone Then
ActiveWindow.ViewType = ppViewSlide
ActiveWindow.ViewType = ppViewSlideSorter

If ActiveWindow.Selection.Type = ppSelectionSlides Then
CurrentSlideIndex = ActiveWindow.Selection.SlideRange.SlideIndex
ActivePresentation.Slides.InsertFromFile _
"S:\FILENAME.ppt", CurentSlideIndex, 1, Last
ActiveWindow.ViewType = ppViewNormal
Else
CurrentSlideIndex = 0 ' no slides
End If
Else
CurrentSlideIndex = ActiveWindow.Selection.SlideRange.SlideIndex
End If

I want to use this same macro for adding another presentation (Pres A) into my current presentation (Pres B) - However Pres A changes in size from month to month and thus the slide index will always need changing - is there a work around?

John Wilson
08-02-2011, 01:46 AM
It's not at all clear what the problem is.

Are you adding the slides in Slide Sorter View?
Are you adding ALL the slides from B (this is the default)

Last in your code must refer to something you have not attached but it is almost certainly not required.

Maybe this:

Sub FI_EconomicUpdate()
Dim CurrentSlideIndex As Long
'makes sure that a slide is selected (not cursor between slides)
ActiveWindow.ViewType = ppViewSlideSorter
ActiveWindow.ViewType = ppViewNormal

'Adds all slides at cursor position
CurrentSlideIndex = ActiveWindow.View.Slide.SlideIndex
ActivePresentation.Slides.InsertFromFile "S:\FILENAME.ppt", Index:=CurrentSlideIndex
End Sub

twnty2
08-02-2011, 05:55 PM
works. Thanks!

twnty2
10-14-2012, 04:40 PM
hi,

im now using 2010 and the CurrentSlideIndex doesnt seem to work, any solutions available?

John Wilson
10-15-2012, 12:43 AM
I can confirm that I see this too. It SHOULD work AFAIK and I will report it as a bug.

John Wilson
10-15-2012, 07:19 AM
EDIT

I take it back. The file path I was adding was incorrect. It works perfectly in 2010 here.

This is a little more robust

Sub FI_EconomicUpdate()
Dim CurrentSlideIndex As Long
Dim osld As Slide
On Error Resume Next
'makes sure that a slide is selected (not cursor between slides)
ActiveWindow.ViewType = ppViewSlideSorter
ActiveWindow.ViewType = ppViewNormal
Set osld = ActiveWindow.View.Slide
'Adds all slides at cursor position
If Not osld Is Nothing Then
CurrentSlideIndex = osld.SlideIndex

ActivePresentation.Slides.InsertFromFile "S:\FILENAME.ppt", Index:=CurrentSlideIndex
Else
MsgBox "Select a slide!!"
End If
End Sub