none
Same TaskPane in multiple PowerPoint windows RRS feed

  • Question

  • I need a single instance of my custom task pane on all active presentations (and windows).

    Private Sub Application_NewPresentation(ByVal Pres As PPT.Presentation) 
    'Handles Application.NewPresentation, Application.PresentationOpen
        myUserControl1 = New TTaskPane1
        myCustomTaskPane = CustomTaskPanes.Add(myUserControl1, "Test1")
        myCustomTaskPane.Visible = True
        myCustomTaskPane.Width = 260
    End Sub

    Current code

    1. Works fine with new presentations via Ctrl+N (Application.NewPresentation)

    2. Will start another instance of Task Pane even if one is already visible if an old presentation is opened (Application.PresentationOpen)

    I believe this happens because TaskPane is associated with a Window, not a presentation. Hence, new presentation (=new window) works and opening presentation (=old window with a Task Pane already) does not.

    Sunday, May 25, 2014 2:58 PM

Answers

  • Hi,

    Based on the code, the instance of Task Pane is only created when you create a new presentation. It will not create a new instance when you open the existing presentation.

    Whatever, you want to add TaskPane for the presentations opened and show only one instance. I suggest you declaring the variable to store the presentations which have associated with custom TaskPane when you create a custom TaskPane every time. Then you can create a new TaskPane instance only the presentation which hasn't been associated with TaskPane.

    Hope it is helpful.

    Best regards

    Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Monday, May 26, 2014 8:45 AM
    Moderator
  • Whatever, you want to add TaskPane for the presentations opened and show only one instance. I suggest you declaring the variable to store the presentations which have associated with custom TaskPane when you create a custom TaskPane every time. Then you can create a new TaskPane instance only the presentation which hasn't been associated with TaskPane.

    Hi,

    thanks for your advice. A minor issue is that TaskPane is associated with DocumentWindow rather than Presentation. Therefore, the solution looks like this:

        Private listOfWindows As New List(Of Integer) 
    
    Private Sub Application_OpenPresentation(ByVal Pres As PPT.Presentation) Handles Application.AfterPresentationOpen, Application.AfterNewPresentation
    
            'Checks if the current window handle exists in the list of TaskPanes
            If listOfWindows.Contains(Application.ActiveWindow.HWND) Then
                'Do nothing, TaskPane has been added previously
            Else
                'Add TaskPane
                myUserControl1 = New TTaskPane1
                myCustomTaskPane = CustomTaskPanes.Add(myUserControl1, " ", Application.ActiveWindow)
                myCustomTaskPane.Visible = True
                myCustomTaskPane.Width = 260
    
                'Add reference to the current DocumentWindow to the list
                listOfWindows.Add(Application.ActiveWindow.HWND)
            End If
        End Sub

    Thanks!

    • Marked as answer by herrpuqq Monday, May 26, 2014 9:40 AM
    Monday, May 26, 2014 9:40 AM

All replies

  • Hi,

    Based on the code, the instance of Task Pane is only created when you create a new presentation. It will not create a new instance when you open the existing presentation.

    Whatever, you want to add TaskPane for the presentations opened and show only one instance. I suggest you declaring the variable to store the presentations which have associated with custom TaskPane when you create a custom TaskPane every time. Then you can create a new TaskPane instance only the presentation which hasn't been associated with TaskPane.

    Hope it is helpful.

    Best regards

    Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Monday, May 26, 2014 8:45 AM
    Moderator
  • Whatever, you want to add TaskPane for the presentations opened and show only one instance. I suggest you declaring the variable to store the presentations which have associated with custom TaskPane when you create a custom TaskPane every time. Then you can create a new TaskPane instance only the presentation which hasn't been associated with TaskPane.

    Hi,

    thanks for your advice. A minor issue is that TaskPane is associated with DocumentWindow rather than Presentation. Therefore, the solution looks like this:

        Private listOfWindows As New List(Of Integer) 
    
    Private Sub Application_OpenPresentation(ByVal Pres As PPT.Presentation) Handles Application.AfterPresentationOpen, Application.AfterNewPresentation
    
            'Checks if the current window handle exists in the list of TaskPanes
            If listOfWindows.Contains(Application.ActiveWindow.HWND) Then
                'Do nothing, TaskPane has been added previously
            Else
                'Add TaskPane
                myUserControl1 = New TTaskPane1
                myCustomTaskPane = CustomTaskPanes.Add(myUserControl1, " ", Application.ActiveWindow)
                myCustomTaskPane.Visible = True
                myCustomTaskPane.Width = 260
    
                'Add reference to the current DocumentWindow to the list
                listOfWindows.Add(Application.ActiveWindow.HWND)
            End If
        End Sub

    Thanks!

    • Marked as answer by herrpuqq Monday, May 26, 2014 9:40 AM
    Monday, May 26, 2014 9:40 AM