gjvdkamp
Posts: 39
Joined: 2018-08-28
|
Hi,
I have a COM addin for Excel with Advanced taskpanes.
I need to get the workbook for the window the taskpane is shown for (SDI).
I have a class MyTaskPane that derives from ADXExcelTaskPane, for every new workbook this gets instantiated (async from wokbook.open it appears..)
I tried accessing the WindowObj in the constructor of MyTaskPane, but that throw a null expcepetion (it doesn't just return null...).
How can I get the workbook the current Advanced Taskpane is 'associated with'?
Right now my setup is a little klunky looking at ExcelApp.ActiveWorkbook b/c I had to support 2010 MDI before, but running into some isssues with that now, was hoping there might be a more robust way. |
|
Andrei Smolin
Add-in Express team
Posts: 17493
Joined: 2006-05-11
|
Hello gjvdkamp,
You should get ADXExcelTaskPane.WindowObj in the ADXExcelTaskPane.ADXTaskPaneBeforeShow. You may need to reverse your logic: you can switch from controlling the pane from the add-in module's events to letting the form react to events, including events raised by the module. In this case, you won't need to do anything in the constructor of the add-in module.
Regards from Belarus (GMT+3),
Andrei Smolin
Add-in Express Team Leader |
|
gjvdkamp
Posts: 39
Joined: 2018-08-28
|
Got it thx
private void MessageNavigatorTaskPane_ADXBeforeTaskPaneShow(object sender, ADXBeforeTaskPaneShowEventArgs e) {
var o = WindowObj as Microsoft.Office.Interop.Excel.Window;
var wb = o.Parent as Microsoft.Office.Interop.Excel.Workbook;
} |
|
Andrei Smolin
Add-in Express team
Posts: 17493
Joined: 2006-05-11
|
Welcome!
Regards from Belarus (GMT+3),
Andrei Smolin
Add-in Express Team Leader |
|