回答第一个问题:
' The mouse cursor can be placed between slide thumbnails in the following views:
' - Normal View / Thumbnail Pane
' - Slide Sorter View
' - Slide Master View / Thumbnail Pane
' Returns true if the cursor is in the slide gap in these cases.
Function IsSlideGap() As Boolean
On Error Resume Next
With ActiveWindow
Select Case .View.Type
Case ppViewNormal, ppViewSlideMaster
' If the thumbnail pane (ViewType 11 or 12 ) is active but
' nothing is selected, we must be in the slide gap
If .Panes(1).Active And .Selection.Type = ppSelectionNone Then IsSlideGap = True
Case ppViewSlideSorter
If .Selection.Type = ppSelectionNone Then IsSlideGap = True
End Select
End With
End Function
回答第二个问题:
' Note: used by slide/gap context menus only so assumes
' either thumbnail pane or sorter view active
Function GetSlideCursorIndex() As Long
Dim lSlides As Long ' Track the number of slides in order
' to check if the temporary slide was deleted.
Dim oSld As Slide
lSlides = ActivePresentation.Slides.Count
' Insert a temporary new slide
CommandBars.ExecuteMso "SlideNew"
DoEvents
Set oSld = ActiveWindow.View.Slide
With oSld
GetSlideCursorIndex = .SlideIndex
.Delete
End With
If ActivePresentation.Slides.Count <> lSlides Then Debug.Print "Something went wrong!"
End Function