Task Pane Instance not seen in AddInModule.OnAddInStartupComplete

Add-in Express™ Support Service
That's what is more important than anything else

Task Pane Instance not seen in AddInModule.OnAddInStartupComplete
Strange behaviour dependent on Office version 
Micha? G??bowski


Guest


Dear Sirs,

I develop Add-In for Excel on W7/64, Office 2007 32bit, XE7.
I have about 4 task panes.

In event AddInModule.OnAddInStartupComplete I have code:

  if adxExcelTaskPanesManager.Items[0].TaskPaneInstance = nil then
    ShowMessage('nil1')
  else
    ShowMessage('ok1');
  
  if adxExcelTaskPanesManager.Items.Items[0].TaskPaneInstance = nil then
    ShowMessage('nil2')
  else
    ShowMessage('ok2');

When I run my code on my develop machine I get ok1 and ok2.
When I run it on my virtual Windows 7/32 with Office 2013 I get nil1 and nil2.

How to be able to get "ok" on every system config?

Hint: in Office 2007 I already can see TaskPanes when dialog shows "ok1"/"ok2". In office 2013 excel is not seen (besides Excel loading small green window) and efter pressing OK on messages there is a window to select document type to open before. It seems that for Excel 2013 OnAddInStartupComplete event is fired too early. I checked, that OnRibbonLoaded fires even earlier and OnTaskPaneAfterCreate does not fire at all.

Michal
Posted 17 Jul, 2015 17:08:58 Top
Andrei Smolin


Add-in Express team


Posts: 18828
Joined: 2006-05-11
Hello Micha?,

Here's a citation from the manual:

It is essential that Add-in Express panes are built on the windowing of the host application, not on the events of the application's object model. This means that getting an instance of an Add-in Express pane in a certain event may result in getting nil if the call is issued before the pane is shown or after it is hidden.


We suggests modifying the code of the add-in so that it gets notified about a pane instance being shown or hidden (instead of getting the pane instance by handling OnAddInStartupComplete). Use the ADXBeforeTaskPaneShow event of the task pane class (Excel, Word, and PowerPoint) and the TadxOlForm.ADXBeforeFormShow (Outlook) event to be notified about the specified pane instance being shown. When the form becomes hidden you'll get TadxOlForm.ADXAfterFormHide (Outlook) and the ADXAfterTaskPaneHide event of the task pane class (Excel, Word, and PowerPoint).


Andrei Smolin
Add-in Express Team Leader
Posted 20 Jul, 2015 04:32:53 Top
Micha? G??bowski


Guest


Hello Andrei,

The problem is I wanted to deal with panels before showing them (specifically, I wrote some class which connected some toggle buttons of ribbon with showing/hiding panels (and vice versa) and tried to assign events in runtime).

But from your citation I understand that I am unable to deal with panels without showing them first. If you wish to look at my code I'll send you that.

Michal
Posted 20 Jul, 2015 06:29:08 Top
Andrei Smolin


Add-in Express team


Posts: 18828
Joined: 2006-05-11
Micha?,

You can use the ADXBeforeFormShow/ADXBeforeTaskPaneShow and ADXAfterFormHide/ADXAfterTaskPaneHide events to change the state of these Ribbon controls.


Andrei Smolin
Add-in Express Team Leader
Posted 20 Jul, 2015 06:40:28 Top
Micha? G??bowski


Guest


Right, but I do it already.
The problem is that I assign these event runtime.
And I fail due to my TaskPaneInstances are nil yet.

here is part of my code

  tpi := FPanesCollection.Items[APaneIndex].TaskPaneInstance;
  if tpi = nil then
    // _('Panels not found...')
  else begin
    tpi.Tag := APaneIndex;
    tpi.OnADXAfterTaskPaneHide := InternalTaskPaneHide;
    tpi.OnADXAfterTaskPaneShow := InternalTaskPaneShow;
  end;


I assume that I cannot do it automatically as I tried.

Michal
Posted 20 Jul, 2015 07:31:00 Top
Andrei Smolin


Add-in Express team


Posts: 18828
Joined: 2006-05-11
Micha?,

You can connect these events in the constructor of the pane instance.


Andrei Smolin
Add-in Express Team Leader
Posted 20 Jul, 2015 08:03:17 Top
Micha? G??bowski


Guest


Andrei,

Your solution requires copying the same code to each of panel what I wanted to avoid. I wanted to do it externally iterating through all panels, but I am aware now that it can be impossible before panels shown.

Michal
Posted 20 Jul, 2015 14:53:31 Top
Andrei Smolin


Add-in Express team


Posts: 18828
Joined: 2006-05-11
Hello Micha?,

You can create a base class for you forms.


Andrei Smolin
Add-in Express Team Leader
Posted 21 Jul, 2015 08:11:44 Top