Get dynamic buttons objects when host application loads

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

Get dynamic buttons objects when host application loads
 
keren friedman




Posts: 16
Joined: 2006-07-27
Hi,

I have added sucessfuly buttons to my Excel add-in menu (ADXCommandBarPopUp) on run time. After I close the Excel and reopen it I see those buttons but cannot accessed them in code.
The Controls and Collection properties of the ADXCommandBarPopUp object are empty as in design time.

What I basically want to do is to go over all buttons that were added and read their caption.

foreach (AddinExpress.MSO.ADXCommandBarControl myCtrl in MyMenu.Controls)
{
myList.Add(myCtrl.Caption);
}

I tried to put the loop in AddinModule_AddinStartupComplete and in AddinModule_AddinInitialize but got the empty collections in both times.

How can I do it?
Posted 27 Jul, 2006 04:07:56 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Keren.

If you add all items at the runtime, you also need to connect them at the runtime.
Please look at the following example:
http://www.add-in-express.com/projects/exceldynamiccontrols.zip
Posted 27 Jul, 2006 09:38:39 Top
keren friedman




Posts: 16
Joined: 2006-07-27
Hi Sergey,

My code is like in the sample only I didn't add the dynamic buttons at AddinModule_AddinStartupComplete event but in a code that is excuted as a result of a click on anther button.
In the startup I only want to read the buttons that were added. What suprises me is that I can see the buttons but the collection is stil empty.
Should dynamic conrtols be added only in the StartupComplete event?
Posted 27 Jul, 2006 16:18:39 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Keren.

In order to see buttons in the collection you need to add them at the design-time.
In Excel you can add dynamic controls wherever you like except for the AddinInitialize event handler.
Posted 28 Jul, 2006 19:14:40 Top