LoadBehavior of 9 with built in ribbon buttons

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

LoadBehavior of 9 with built in ribbon buttons
 
nwein




Posts: 577
Joined: 2011-03-28
I'm trying to set my add-in so that it doesn't load automatically upon launch (outlook 2010, 32-bit) but only on demand.
I've changed the ADXAddinModule LoadBehavior to 9 (Connected;LoadOnDemand) to achieve that.
However, I don't have a new ribbon tab in my add-in. I have my ribbon tab's IdMso set to TabMail (the Home tab in Outlook 2010 Explorer) and now When I load my Outlook I don't see the Home tab at all.
I can somewhat understand the rationale behind this (my add-in is using the same tab), but I don't think it should be like that.
If I have a new ribbon tab (i.e. no IdMso) with the latter LoadBehavior, that new ribbon tab will appear even when the add-in is not loaded (to allow on-demand loading).
Why is this not the case when using built-in tab IdMso's?
How can I make my add-in load on demand when my ribbon groups/buttons/controls are in the default Outlook ribbon?
(ADX 7.6.4084)
Posted 29 Dec, 2014 15:16:54 Top
Andrei Smolin


Add-in Express team


Posts: 18823
Joined: 2006-05-11
Hello Nir,

You'd need to use LoadBehavior=16 (ConnectFirstTime). When you start the host application for the first time and then close it, Office sets the LoadBehavior registry value to 9. Alas, I replicate the issue in this scenario as well. It is now filed under #6199 in our bug-tracking DB. We will be able to look at this in the new year, starting from January, 5.

As soon as I have any news on this issue, I'll let you know.


Andrei Smolin
Add-in Express Team Leader
Posted 30 Dec, 2014 04:13:21 Top
nwein




Posts: 577
Joined: 2011-03-28
Thanks for looking into this.
Happy new year!
Posted 30 Dec, 2014 10:13:39 Top
Andrei Smolin


Add-in Express team


Posts: 18823
Joined: 2006-05-11
Hello Nir,

We've reproduced this issue in a VSTO add-in. It only occurs if a tab element in the Ribbon XML contains both the IdMso and getVisible attributes. You can use the ReplaceGetVisibleWithVisible method (see below VB.NET and C# versions) as a workaround. You call this method in the OnRibbonBeforeLoad event of the add-in module as demonstrated in the examples supplied below. Note that replacing the getVisible attribute with the visble one makes the tab visibility static; you cannot change the visibility of such a tab at run time.

Hope this helps.


Andrei Smolin
Add-in Express Team Leader

Private Function ReplaceGetVisibleWithVisible(ByVal incomingXML As String, ByVal ribbonTab As ADXRibbonTab, Optional ByVal visible As Boolean = True) As String 
    Dim result As String = String.Empty 
 
    Dim lines As String() = incomingXML.Split(Environment.NewLine) 
 
    For i As Integer = 0 To lines.Length - 1 
        If (ribbonTab.IdMso <> String.Empty) Then 
            If (lines(i).Contains("idMso=""" + ribbonTab.IdMso)) Then 
                lines(i) = lines(i).Replace("getVisible=""getVisible_Callback""", "visible=""" & visible.ToString().ToLower() + """") 
                Exit For 
            End If 
        End If 
    Next 
 
    For i As Integer = 0 To lines.Length - 1 
        result += lines(i) + Environment.NewLine 
    Next 
    Return result 
End Function 
 
Private Sub AddinModule_OnRibbonBeforeLoad(ByVal sender As System.Object, ByVal e As AddinExpress.MSO.ADXRibbonBeforeLoadEventArgs) Handles MyBase.OnRibbonBeforeLoad 
    e.Xml = ReplaceGetVisibleWithVisible(e.Xml, AdxRibbonTab1, True) 
    e.Xml = ReplaceGetVisibleWithVisible(e.Xml, AdxRibbonTab2, True) 
End Sub 


private string ReplaceGetVisibleWithVisible(string ribbonXML, ADXRibbonTab aBuiltinRibbonTab, bool visible) 
{ 
    string[] lines =  
        ribbonXML.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); 
    for (int i = 0; i < lines.Length; i++) 
    { 
        if (lines[i].Contains(aBuiltinRibbonTab.IdMso)) 
        { 
            lines[i] = lines[i].Replace(@"getVisible=""getVisible_Callback""",  
                @"visible="""+ visible.ToString().ToLower() + @""""); 
            break; 
        } 
    } 
    string result = string.Empty; 
    for (int i = 0; i < lines.Length; i++) 
        result += lines[i] + Environment.NewLine; 
 
    return result; 
} 
private void AddinModule_OnRibbonBeforeLoad(object sender, ADXRibbonBeforeLoadEventArgs e) 
{ 
    e.Xml = ReplaceGetVisibleWithVisible(e.Xml, adxRibbonTab1, true); 
    e.Xml = ReplaceGetVisibleWithVisible(e.Xml, adxRibbonTab3, false); 
} 
Posted 05 Mar, 2015 09:37:57 Top
nwein




Posts: 577
Joined: 2011-03-28
Thanks, I'll give it a try
Posted 05 Mar, 2015 11:05:57 Top