M
Martin Stender
Hi all,
I have a bit of trouble inserting slides in the correct place, when the
slidesorter is in focus and the user has not actually selected a slide.
(f.x. if the curser is inserted between two slides).
Paste the following into a commandbutton (and add a few slides):
Private Sub CommandButton1_Click()
If ActiveWindow.Presentation.Slides.Count = 0 Then
currSlide = 0
debugMsg = "empty presentation"
ElseIf ActiveWindow.Selection.Type = ppSelectionSlides Then
currSlide = ActiveWindow.Selection.SlideRange.SlideIndex
debugMsg = "selected slide in slidesorter"
ElseIf ActiveWindow.Selection.Type = ppSelectionNone Or _
ppSelectionShapes Or ppSelectionText Then
'this is where the code fails
currSlide = ActiveWindow.View.Slide.SlideIndex
debugMsg = "none, shapes or text"
Else
currSlide = ActivePresentation.Slides.Count 'last slide
debugMsg = "last slide"
End If
Debug.Print currSlide, debugMsg
'in real life the following would be insertFromFile'
ActivePresentation.Slides.Add Index:=currSlide + 1, _
Layout:=ppLayoutBlank
ActiveWindow.View.GotoSlide currSlide + 1
End Sub
I can of course insert an "On Error Resume Next", but then the user
will just be mystified, when nothing happens.
Any suggestions?
Thanks in advance
Martin
I have a bit of trouble inserting slides in the correct place, when the
slidesorter is in focus and the user has not actually selected a slide.
(f.x. if the curser is inserted between two slides).
Paste the following into a commandbutton (and add a few slides):
Private Sub CommandButton1_Click()
If ActiveWindow.Presentation.Slides.Count = 0 Then
currSlide = 0
debugMsg = "empty presentation"
ElseIf ActiveWindow.Selection.Type = ppSelectionSlides Then
currSlide = ActiveWindow.Selection.SlideRange.SlideIndex
debugMsg = "selected slide in slidesorter"
ElseIf ActiveWindow.Selection.Type = ppSelectionNone Or _
ppSelectionShapes Or ppSelectionText Then
'this is where the code fails
currSlide = ActiveWindow.View.Slide.SlideIndex
debugMsg = "none, shapes or text"
Else
currSlide = ActivePresentation.Slides.Count 'last slide
debugMsg = "last slide"
End If
Debug.Print currSlide, debugMsg
'in real life the following would be insertFromFile'
ActivePresentation.Slides.Add Index:=currSlide + 1, _
Layout:=ppLayoutBlank
ActiveWindow.View.GotoSlide currSlide + 1
End Sub
I can of course insert an "On Error Resume Next", but then the user
will just be mystified, when nothing happens.
Any suggestions?
Thanks in advance
Martin