AddinExpress 7.1.4050 in Excel 2013

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

AddinExpress 7.1.4050 in Excel 2013
Taskpane initialised later in contrast to Excel 2007 or before 
Ramesh Shrestha




Posts: 63
Joined: 2011-01-03
In excel 2007 and 2003, ADXBeforeTaskPaneInstanceCreate event is called before AddinStartupComplete event, after calling the ADXBeforeTaskPaneInstanceCreate event TaskPaneClass is called automatically.

But in 2013, the ADXBeforeTaskPaneInstanceCreate event is called after AddinStartupComplete, due to which we are not able to access taskpane instance in AddinStartupComplete event.

Is the order of taskpane initialisation different in Excel 2013? If yes, can you please forward us the event or method so that we can initialize the TaskPaneClass before the AddinStartupComplete?
Posted 04 Jan, 2013 01:16:56 Top
Andrei Smolin


Add-in Express team


Posts: 18825
Joined: 2006-05-11
Hello Ramesh,

The order of events depends on Excel version and on the way you start Excel. The same applies to the order in which Excel windows are created. That is, the answer to your question is Yes, the order in which ADXExcelTaskPane classes are initialized depends on the factors above.

Ramesh Shrestha writes:
If yes, can you please forward us the event or method so that we can initialize the TaskPaneClass before the AddinStartupComplete?


May I know what you need to achieve? If you need to prevent a task pane from showing, the recommended way is to set ADXExcelTaskPane.Visible=False in the ADXExcelTaskPane.ADXBeforeTaskPaneShow event.


Andrei Smolin
Add-in Express Team Leader
Posted 04 Jan, 2013 03:16:25 Top
Ramesh Shrestha




Posts: 63
Joined: 2011-01-03
Hi Andrie,
Thanks for the reply,
Would please tell me, what is the best way to initialize taskpane, before AddinStartupComplete event, so that i can use the taskpane in the event called.
Earlier in 2007 and 2003, initializing taskpane as shown in the snapshot
User added an image

Doing same, is not working for 2013, the event order is not in right order. How to achieve this in 2013?

I'm looking forward to you.
Posted 04 Jan, 2013 04:24:57 Top
Andrei Smolin


Add-in Express team


Posts: 18825
Joined: 2006-05-11
Ramesh Shrestha writes:
Would please tell me, what is the best way to initialize taskpane, before AddinStartupComplete event, so that i can use the taskpane in the event called.


I don't understand. Can you please re-word the above?

Thank you for the scheme. Unfortunately, I don't understand it either. May I have some code? You can send it to the support email address (please find it in readme.txt); make sure that your email contains a link to this topic.

I understand you so that you need to have a task pane initialized (whatever this means) in the AddinStartupComplete event. Is this correct? If yes, can you please explain why you need this?


Andrei Smolin
Add-in Express Team Leader
Posted 04 Jan, 2013 04:53:22 Top
Ramesh Shrestha




Posts: 63
Joined: 2011-01-03
hi Andrei,

1) I have to initialize other object after the Taskpane (dxExcelTaskPanesManager) object initialization have been completed.
2) Since adxExcelTaskPanesManager have no such Event. I been doing that at AddinStartupComplete since (excel 2003..2010).
3) Suddenly from Excel-2013 adxExcelTaskPanesManager initilize been start after AddinStartupComplete.

so since the sequence of dxExcelTaskPanesManager initilization been changed for 2013 I have to change my huge code.

Regards from Ramesh
Posted 09 Jan, 2013 04:01:34 Top
Andrei Smolin


Add-in Express team


Posts: 18825
Joined: 2006-05-11
Hi Ramesh,

Architecting the code so that it relies on the order of events isn't correct. As explained above, the order of events depends on the Excel version AND ALSO on the way you start Excel. Add-in Express doesn't (and cannot) do anything in this area; all these events are generated by Excel.

ADXExcelTaskPane provides the ADXBeforeTaskPaneShow event. In this event you can set a flag indicating that a given task pane type is being shown; that is, if you have two task panes, then you need to have two flags. In the same event, right after setting the flag, you call a method that analyzes all flags and performs the initialization if all flags are set.

AddinModule:
public bool IsInitialized = false;
public bool IsPane1Shown = false;
public bool IsPane2Shown = false;

public void Initialize()
{
    if (IsPane1Shown && IsPane2Shown)
    {
        // Initialization
        IsInitialized = true;
        MessageBox.Show("Initialized!");
    }
}


Pane1:
private void ADXExcelTaskPane1_ADXBeforeTaskPaneShow(object sender, ADXBeforeTaskPaneShowEventArgs e)
{
    if (!MyAddin5.AddinModule.CurrentInstance.IsInitialized)
        this.ADXPostMessage(IntPtr.Zero, IntPtr.Zero);
}

private void ADXExcelTaskPane1_ADXPostMessageReceived(object sender, ADXPostMessageReceivedEventArgs e)
{
    MyAddin5.AddinModule.CurrentInstance.IsPane1Shown = true;
    MyAddin5.AddinModule.CurrentInstance.Initialize();
}


Pane2:
private void ADXExcelTaskPane2_ADXBeforeTaskPaneShow(object sender, ADXBeforeTaskPaneShowEventArgs e)
{
    if (!MyAddin5.AddinModule.CurrentInstance.IsInitialized)
        this.ADXPostMessage(IntPtr.Zero, IntPtr.Zero);
}

private void ADXExcelTaskPane2_ADXPostMessageReceived(object sender, ADXPostMessageReceivedEventArgs e)
{
    MyAddin5.AddinModule.CurrentInstance.IsPane2Shown = true;
    MyAddin5.AddinModule.CurrentInstance.Initialize();
}


Discussion. When a pane is about to be shown, it checks if initialization is required. If positive, it calls the PostMessage method which creates a delay (sort of timer) before the ADXPostMessageReceived event occurs; the event occurs after the task pane is shown. In the event handler for the ADXPostMessageReceived, you set a flag and call the method which checks all flags and performs the initialization.

CurrentInstance is a property defined in the code of the add-in module.


Andrei Smolin
Add-in Express Team Leader
Posted 09 Jan, 2013 06:23:16 Top
Ramesh Shrestha




Posts: 63
Joined: 2011-01-03
Thanks,
Now I understand

Regards from Ramesh
Posted 10 Jan, 2013 02:36:52 Top