Craig Schwarze
Craig Schwarze

Reputation: 11615

Outlook addin has failed to find Office control by ID

I've just built an MS Outlook Add In using Visual Studio and Office 2010. I've installed it ok on 4 machines, but one user is getting the following error -

Error found in Custom UI XML of "...."
...
...
Failed to find Office control by ID

Everyone is running Windows 7 and Outlook 2010 - not sure why this person is having a problem. Can anyone suggest how to diagnose this?

Upvotes: 3

Views: 6832

Answers (4)

Fritsch
Fritsch

Reputation: 11

For all of you that use a Designer-based VSTO plugin, and not the XML solution. I searched all the web for this problem, but only found XML-based solutions. There's nothing for Visual Designer on the web, because in this case you don't have to override the "GetCustomUI" method. Ribbons designed by using the Visual Designer return a RibbonManager by default. This RibbonManager object represents all Ribbon (Visual Designer) items in the project and is automatically handled in background through the active window inspector. So you don't have to write any special code to handle different windows.

To configure it correctly you just have to:

  • Add one extra Visual Designer Ribbon for every window the user goes to
  • in the Ribbon Object go under "RibbonType", open the checkbox list an only activate the corresponding window, where the ribbon should appear.

If there is more than one window checked in the list, Outlook trys to insert the ribbon in all the marked windows. Even if the corresponding window is currently not opened. That's the reason, why the error "Failed to find control ID" appears.

Upvotes: 1

Aussie Ash
Aussie Ash

Reputation: 1336

the actual fix for me was to separate the ribbon XML files containing the customUI and redirecting to the correct one in the GetCustomUI method (implemented using Office.IRibbonExtensibility) in example:

public string GetCustomUI(string RibbonID)
    {
        switch (RibbonID)
        {
            case "Microsoft.Outlook.Mail.Read":
                return GetResourceText("namespace.type1.xml");
            case "Microsoft.Outlook.Mail.Compose":
                return GetResourceText("namespace.type2.xml");
            default:
                return null;
        }
    }

Upvotes: 0

Hochman7G
Hochman7G

Reputation: 174

For those having similar issues, you don't have to remove any add-in. What is happening is: Outlook will try to load all ribbons (found in your ribbon xml) into any window the user goes to. Then it'll complain about not finding ID x or y.

Just make sure your GetCustomUI method in Ribbon.cs does not load the entire ribbon XML at once but rather loads it per fragment.

If you're not sure what IDs you need to target, use a breakpoint in GetCustomUI then start Outlook, surf different views (main, new email, new appointment, calendar...etc) in order to gather the IDs for the views wherein you need to show you add-in.

In my case, I needed Microsoft.Outlook.Explorer, Microsoft.Outlook.Mail.Compose and Microsoft.Outlook.Appointment.

Therefore I changed my GetCustomUI to:

    public string GetCustomUI(string ribbonID)
    {
        switch (ribbonID)
        {
            case "Microsoft.Outlook.Explorer":
                return GetResourceText("MyAddin.RibbonsForOutlookExplorer.xml");
            case "Microsoft.Outlook.Mail.Compose":
                return GetResourceText("MyAddin.RibbonForOutlookMailCompose.xml");
            case "Microsoft.Outlook.Appointment":
                return GetResourceText("MyAddin.RibbonForOutlookAppointment.xml");
            default:
                return null;
        }
    }

Of course, I had to break down my Ribbon.xml into the three XML files mentioned above. The result: Outlook will ONLY load the fragment needed for a given screen (appointment, new email ...) and will not complain about "not finding an ID on screen X or Y".

Finally, for those who are not sure why some users get that error while others don't: it's because of "Show add-in user interface errors" option (in Options -> Advanced). If that is unchecked then Outlook will ignore the malformed ribbon XML errors. If it checked, users will get related errors about your add-in (if any exists) and also about other add-ins.

Upvotes: 13

Kiru
Kiru

Reputation: 3565

If it works for everyone except one user. As @Brijesh Mishra mentioned check if the user has got any other addin and if he is having own quick access tool bar customized.

If he has got any of this then, remove the other addins and try to install or reset the quick access tool bar customization.

Upvotes: 2

Related Questions