Custom Task Pane - PowerPoint Addin and DocumentWindow Problem

Hi,

I noticed an oddity while trying to track a Custom Task Pane among Powerpoint windows in my Addin.

I built an Addin for PowerPoint and it uses Custom Task Panes, and my intention was so that every presentation window would have its own instance of the Task Pane, which is very easy to do, once Addin.CustomTaskPanes.Add allows me to associate a panel to one specific window. I tried then to make a toogle button for my Custom Task Pane, associated to its visibility. I understand that the Ribbon has a single instance at runtime, and runs in Application level, instead of Document level, hence I needed to sync the Checked property of the toogle button to the visibility of the Custom Task Pane on that window once the window became active. Ok. And this is where I noticed an oddity:

Private Sub CTPs_SyncVisibility(Pres As PowerPoint.Presentation, Wn As PowerPoint.DocumentWindow)
'This handles Globals.PPTAddIn.Application.WindowActivate; Wn is a reference to the just activated window

For Each ctp As CustomTaskPane In Globals.PPTAddIn.CustomTaskPanes 
If ctp.Window Is Wn Then 
'Change the toogle button's Checked Property   
End If 
Next 
End Sub


When multiple presentation windows are open, each with its own taskpane associated, the line > If ctp.Window Is Wn Then <will aways return true, for every taskpane, implying that every taskpane is associated to the window that became active, making it impossible to determine in which window a given taspane is.

Through some exploration I noticed a couple of things:

1. It's not a problem with Powerpoint Windows direct comparison, once the folowing lines of code return the expected result:

'Assume here that .Windows(1) is the actual active window
Dim asw = Globals.PPTAddIn.Application.ActiveWindow Is Globals.PPTAddIn.Application.Windows(2)     '-> False
Dim asw2 = Globals.PPTAddIn.Application.ActiveWindow Is Globals.PPTAddIn.Application.Windows(1)     '-> True 
Dim asw3 = Globals.PPTAddIn.Application.Windows(1) Is Globals.PPTAddIn.Application.Windows(2)      '-> False

2. It doesn't seem to be a problem related to the property CustomTaskPane.Window once I tried to store the window reference in other property, like .Tag, during the instanciation of the Taskpanes, and it still yields the same weird result of True for every Taskpane regardless of in which window it is.


So, my questions are: Is this a well known misbehavior of the Custom Task Pane? Does this happens somehow beacuse it is a COM object (the window)? Am I plain dumb and this is not the way it's supposed to be done? And lastly, which method should I use to track down in which window is my taskpane?

I thank you in advance,

Mximo

April 16th, 2015 5:42pm

Hi,

This is the forum to discuss questions and feedback for Microsoft Office client. For any Office development related issues, I would suggest you to post in the forum of Office for Developers, where you can get more experienced responses:

https://social.msdn.microsoft.com/Forums/office/en-US/home?category=officedev

The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.

Regards,

Ethan Hua
TechNet Community Support

Free Windows Admin Tool Kit Click here and download it now
April 24th, 2015 4:41am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics