CustomTaskPanes explanation required
It seems, custom task panes are shared among all workbooks within Excel process, as Cu开发者_JAVA技巧stomTaskPanes property is on the add-in object level and thus it's shared among all workbooks. (am I right?)
I need to show different contents in the task pane for different workbooks, how can I achieve that?You are right, custom task panes are registered at an application level.
Out of the box you must use the Ribbon Designer, it doesnt matter if you don't create a ribbon, but it is the best way to achieve what you want. In the loaded event of the ribbon, you need to access Globals.ThisAddin.CustomTaskPanes to register your task pane if it isnt registered, then update the content based on the the current context. Off the top of my head I am not sure what events you will need to hook into, but probably need to know when a new workbook is activated/selected and update the task pane.
I have been working on a project (VSTO Contrib) which tries to solve this disconnect, the RibbonFactory will allow you to register a viewmodel for a object/ribbon type (Word.Document, Outlook.Appointment etc) and you can simply inherit from IRegisterCustomTaskPanes to wire up a custom task pane for that workbook/document/any other context. It will take care of all the synchronisation for you. Have a read of what it can do at http://jake.ginnivan.net/vsto-contrib/ribbon-factory Feel free to contact me or post here for more info.
Action Panes are the per document equivilent functionality under 2007/2010, see MSDN Action Panes.
精彩评论