Task Pane and Data across multiple instance of Excel

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

Task Pane and Data across multiple instance of Excel
 
Jamil Nawaz




Posts: 22
Joined: 2018-02-10
A ribbon control's context is typically a Window object; you need to compare it with the window object returned via ExcelApp.ActiveWindow.

Please note that although widely used the term Ribbon Control is not exactly precise. Your add-in supplies Office with a Ribbon XML (see e.Xml in the OnRibbonBeforeLoad event of your add-in module) that specifies what "controls" to create and a number of callback functions that specify its behavior. Add-in Express provides all the callbacks for you and maps Office calls to the Ribbon components used in your code.

That is, there's no such thing as a Ribbon control shared across several windows; there is the Ribbon XML that specify what how Office draws your control and there are Add-in Express properties and events that let you define how that "control" behaves using the properties/methods/events of the corresponding ribbon component.


That means, if I call "adxRBAzureUpload.Enabled = False" in Workbook1 and it will disable the button in workbook1, in workbook2 the button will still be enable?

adxRBAzureUpload is the Id of the ADXRibbonButton that I define in the designer.

If the problem is not clear, please tell me I'll try to write that.

Regards,
Jamil
Posted 13 Jul, 2018 06:29:59 Top
Andrei Smolin


Add-in Express team


Posts: 15595
Joined: 2006-05-11
Jamil,

Jamil Nawaz writes:
That means, if I call "adxRBAzureUpload.Enabled = False" in Workbook1 and it will disable the button in workbook1, in workbook2 the button will still be enable?


It will work as described in section Updating ribbon controls at run time at https://www.add-in-express.com/docs/net-ribbon-components.php#properties-events. That is, setting e.g. Enabled will modify it on all instances of your "control" if the PropertyChanging event isn't intercepted. To set it differently in different windows, use the other approach described in that section: intercept the PropertyChanging event .

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 13 Jul, 2018 06:48:48 Top
Jamil Nawaz




Posts: 22
Joined: 2018-02-10
Andrei Smolin writes:
To set it differently in different windows, use the other approach described in that section: intercept the PropertyChanging event .


What I understand is,


private void OnPropertyChanging(object sender, ADXRibbonPropertyChangingEventArgs e) { 
   switch (e.PropertyType) { 
       case ADXRibbonControlPropertyType.Caption: 
           if (condition) { 
               e.Value = "Some caption"; 
           } else { 
               e.Value = "Some other caption"; 
           } 
           break; 
       case ADXRibbonControlPropertyType.Enabled: 
           if (condition) { 
               e.Value = true; 
           } else { 
               e.Value = false; 
           } 
           break; 
   } 
}


In the condition, I need to add logic to determine whether I need to enable it or not?

Regards,
Jamil
Posted 13 Jul, 2018 07:10:28 Top
Andrei Smolin


Add-in Express team


Posts: 15595
Joined: 2006-05-11
Yes, there should be some logic providing the value for the condition variable above. I believe you already have it.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 13 Jul, 2018 07:19:29 Top
Jamil Nawaz




Posts: 22
Joined: 2018-02-10
Hi Andrei,

I am doing the implementation according to the discussion in this thread but I am little bit confused. Let me explain here.

In our discussion, we found that to get the specific workbook's task pane instance on the ribbon button click handler, we need to use
adxColumnMappingTaskPane[control.Context]
and we also talk that if we use
adxColumnMappingTaskPane[ExcelApp.ActiveWindow]

Both should be behave same way but those are not.

Here is my use case:
I open the Excel, open the Task Pane using the ribbon button and then I run Excel again (which creates new excel workbook).

Results: In first way, when I open the 2nd workbook, the Task Pane was not show (this is correct behavior).
In 2nd way, the Task Pane shows as Opened (this is incorrect).

From the discussion in previous posts, I understand that ExcelApp.ActiveWindow will provide the current workbook's context.

What do you think why is that?

Please clarify.

Regards,
Jamil
Posted 13 Jul, 2018 08:05:58 Top
Andrei Smolin


Add-in Express team


Posts: 15595
Joined: 2006-05-11
Jamil Nawaz writes:
Results: In first way, when I open the 2nd workbook, the Task Pane was not show (this is correct behavior). In 2nd way, the Task Pane shows as Opened (this is incorrect).


Can the issue be invoked by your code?

Jamil Nawaz writes:
adxColumnMappingTaskPane[control.Context]
adxColumnMappingTaskPane[ExcelApp.ActiveWindow]


In what event do you get these and see the difference?

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 13 Jul, 2018 08:25:32 Top
Jamil Nawaz




Posts: 22
Joined: 2018-02-10
Andrei Smolin writes:
In what event do you get these and see the difference?


adxColumnMappingTaskPane[control.Context]
adxColumnMappingTaskPane[ExcelApp.ActiveWindow]

Both these line I tested in ribbon button click handler.

Regards,
Jamil
Posted 13 Jul, 2018 08:32:53 Top
Andrei Smolin


Add-in Express team


Posts: 15595
Joined: 2006-05-11
May I have the code to test?

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 13 Jul, 2018 08:40:12 Top
Jamil Nawaz




Posts: 22
Joined: 2018-02-10
You want me to send you two sample projects with those different implementations?
Posted 13 Jul, 2018 09:14:27 Top
Andrei Smolin


Add-in Express team


Posts: 15595
Joined: 2006-05-11
Yes, please send them to the support email address; see {Add-in Express installation folder}\readme.txt. Please make sure your email contains a link to this topic.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 13 Jul, 2018 09:16:24 Top