none
PowerPoint: current slide in active presentation RRS feed

  • Question

  • I'm looking at the best way to get the current slide in the active presentation.

    The documentation says that when you are in a NormalView (ActiveWindow.View.Type = pptNormalView) you can access the current slide with ActiveWindow.View.Slide.

    The problem with this approach is that when the user clicks on slides preview pane (left pane), and the focus goes between two slides (see the picture) the ActiveWindow.View.Slide cannot be reached, it throws a null pointer exception.




    Is there a way to access the current slide in any case?

    Thank you, F.
    Tuesday, May 28, 2013 12:19 PM

Answers

  • Hopefully this might help you. If the user's cursor is placed as you indicate then current slide is the one above the selection point. Now if you were tracking last slide selection, you could do something like this to identify the situation and change the active focus.

    Sub WhatSlideWhatSlide()
        Dim sld As Slide
        If ActiveWindow.View.Type = ppViewNormal Then
            If ActiveWindow.Panes(2).Active Then
                MsgBox "Cursor in Slide"
            ElseIf ActiveWindow.Panes(3).Active Then
                MsgBox "Cursor in Notes"
            Else
                MsgBox "Cursor in Side Panel"
                ActiveWindow.Panes.Item(2).Activate
                Set sld = ActiveWindow.View.Slide
                MsgBox sld.SlideNumber
            End If
        End If
    End Sub


    Kind Regards, Rich ... http://greatcirclelearning.com


    Monday, June 3, 2013 10:45 PM

All replies

  • Hi Fabio,

    Thank you for posting in the MSDN Forum.

    Unfortunately, you cannot get the current slide when no slide has focus.

    You can refer to PPT: Sample VB Code to Retrieve Current Slide Number.

    Hope it helps.

    Best regards,


    Quist Zhang [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, May 29, 2013 8:02 AM
    Moderator
  • Hopefully this might help you. If the user's cursor is placed as you indicate then current slide is the one above the selection point. Now if you were tracking last slide selection, you could do something like this to identify the situation and change the active focus.

    Sub WhatSlideWhatSlide()
        Dim sld As Slide
        If ActiveWindow.View.Type = ppViewNormal Then
            If ActiveWindow.Panes(2).Active Then
                MsgBox "Cursor in Slide"
            ElseIf ActiveWindow.Panes(3).Active Then
                MsgBox "Cursor in Notes"
            Else
                MsgBox "Cursor in Side Panel"
                ActiveWindow.Panes.Item(2).Activate
                Set sld = ActiveWindow.View.Slide
                MsgBox sld.SlideNumber
            End If
        End If
    End Sub


    Kind Regards, Rich ... http://greatcirclelearning.com


    Monday, June 3, 2013 10:45 PM