0

在 PowerPoint 中,在“正常”视图中,窗口分为两个窗格,左侧是显示幻灯片缩略图的窗格,右侧是显示当前幻灯片的窗格。您可以在左侧面板中选择多张幻灯片,这在您想要复制、移动或删除幻灯片时很有用。

要判断当前在左侧面板中选择了哪些幻灯片,您可以使用ActiveWindow.Selection.SlideRange. 但是,如果您在左侧(缩略图)面板中的幻灯片之间单击,您最终会得到一个插入点,并且:

  • ActiveWindow.Selection.Type为零 ( ppSelectionNone)。
  • ActiveWindow.Selection.SlideRange给出一个错误。

我有一个问题分为两半:

  1. 我怎样才能发现这种情况?(大概还有其他选择类型为“无”的情况)。
  2. 如何知道插入点在哪里,以便在该点插入新幻灯片?

VBA 或 VSTO 代码都可以:-)

4

2 回答 2

1

回答第一个问题:

' 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
于 2022-01-27T00:22:01.647 回答
0

我刚刚发现这个:http ://skp.mvps.org/pptxp020.htm

摘要:切换到ppViewSlide视图然后再返回,PowerPoint 将选择插入点之前的幻灯片(或第一张幻灯片,如果 IP 位于开头)。

我仍然对避免这种方法固有的屏幕闪烁的更好方法感兴趣(并且理想情况下不会改变选择)。

于 2013-01-08T17:00:40.637 回答