sumu kalshan
Guest
|
Hi
1) I am trying to create a custom task pane for Excel that will work in Excel 2003 and above. Therefore I chose the Adx Advanced Custom Task Panes approach
2) In the ADX Documentation (Development Guide) it is mentioned
"In Excel and PowerPoint, a single instance of the <Fo rm> is always created for a given <Item> because these applications show documents in a single main window"
3) However I see that in Excel 2007 if you have two workbooks open there are two windows and each of them shows the custom task pane
4) My task pane shows information based on the active workbook currently shown. How can I create multiple instances of the custom task pane - one for each window showing relevant information?
Thanks in advance
Sumu |
|
Andrei Smolin
Add-in Express team
Posts: 18838
Joined: 2006-05-11
|
Hi Sumu,
sumu kalshan wrote:
3) However I see that in Excel 2007 if you have two workbooks open there are two windows and each of them shows the custom task pane
In fact, any Excel version can show workbooks in that way. Add-in Express Avanced Task Panes are designed so that they dock to the main Excel window, not to the workbook window. That is, to show a taskpane for the active workbook, you'll need to show the task pane when a workbook becomes activated. Please pay attention to the ADXExcelTaskPane.Activate method. Also, there's a sample project available: see "How to make an Excel task pane visible / invisible programmatically" in http://www.add-in-express.com/support/addin-c-sharp.php#task-panes. The same sample is available in http://www.add-in-express.com/support/addin-vb-net.php
Andrei Smolin
Add-in Express Team Leader |
|
sumu kalshan
Guest
|
Thanks for your tip. In fact I did read the example yesterday after posting and here is the vague approach I took. Any pointers on if this is a reasonable approach will be much appreciated
1) I create a new instance of a taskpane collection item when I know I am going to be opening a workbook. I tag the item with some information and add it to the manager collection. I also do a CreateTaskPaneInstance() on it.
2) On workbook activate I find the taskpane I created earlier and then do a show. On Workbook deactivate I do a Hide.
3) Because all such taskpane instances will try to be shown anyway early on, I trap BeforeTaskPane Show and I set visible=true for the task pane, only if its tag matches the information in the current workbook. So even if it is called out of turn, the task pane will refuse to show itself if it knows it is not the workbook it is tagged for.
So my questions are
1) Is it ok to have so many instances of the task pane? Do you foresee any problems? Is the manager and TaskPane class designed to handle this?
2) is there any specific cleanup I should do? (Right now I am just setting the allocated taskpanes to null on workbook close. Is there any disposal I should take care of?
Thanks
Sumu |
|
Andrei Smolin
Add-in Express team
Posts: 18838
Joined: 2006-05-11
|
Hi Sumu,
ADXExcelTaskPanesManager creates a single task pane instance per collection item. That is, you will not be able to have several instances of the same task pane. You have two ways:
- to have several collection items (you can create them at run-time)
- to have just 1 task pane and replace controls and/or information when a workbook is activated.
Note that if you choose the first approach and there are two (or more) task panes in a given region, Add-in Express will show controls allowing the end-user to switch between task panes.
Andrei Smolin
Add-in Express Team Leader |
|