添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I have an Outlook Addin That Adds a Group to the Ribbon with two buttons. It was working perfectly before I added the second button, but they have the same properties just different click handlers. It shows up in the correct place in the customize ribbon menu, but it is greyed out. What does it mean when it is greyed out and what could cause it? The addin is still loaded and wasn't deactivated for any reason that is on the list of reasons for why addins would be deactivated.

By following this question's answer: Outlook addin Home tab with custom button

I was able to get the button to show on the read mail window on the main tab. The only differences from that answer are I used TabReadMessage rather than TabMail (as per the documentation). This worked perfectly until the 2nd button was added. You can see both buttons in the screnshot, Archive Message and Archive Message As.

See picture:

Anyone have any idea why this could be happening. Why would adding a second button make it stop showing up?

Is there a way to debug this and see what is occurring?

Any help would be appreciated as I've been searching for the answer for a while now.

Thanks

EDIT:

The generated code for my properties of my ribbon elements.

    private void InitializeComponent()
        System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(OutlookRibbon));
        this.tab1 = this.Factory.CreateRibbonTab();
        this.group1 = this.Factory.CreateRibbonGroup();
        this.button1 = this.Factory.CreateRibbonButton();
        this.button2 = this.Factory.CreateRibbonButton();
        this.tab1.SuspendLayout();
        this.group1.SuspendLayout();
        // tab1
        this.tab1.ControlId.ControlIdType = Microsoft.Office.Tools.Ribbon.RibbonControlIdType.Office;
        this.tab1.ControlId.OfficeId = "TabReadMessage";
        this.tab1.Groups.Add(this.group1);
        this.tab1.Label = "TabReadMessage";
        this.tab1.Name = "tab1";
        // group1
        this.group1.Items.Add(this.button1);
        this.group1.Items.Add(this.button2);
        this.group1.Label = "Archive";
        this.group1.Name = "group1";
        this.group1.Position = this.Factory.RibbonPosition.BeforeOfficeId("GroupRespond");
        // button1
        this.button1.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
        this.button1.Description = "Archive Message";
        this.button1.Image = ((System.Drawing.Image)(resources.GetObject("button1.Image")));
        this.button1.Label = "Archive Message";
        this.button1.Name = "button1";
        this.button1.ScreenTip = "Archives Message";
        this.button1.ShowImage = true;
        this.button1.SuperTip = "Archives Message";
        this.button1.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.button1_Click);
        // button2
        this.button2.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
        this.button2.Description = "Archive Message As";
        this.button2.Image = ((System.Drawing.Image)(resources.GetObject("button2.Image")));
        this.button2.Label = "Archive Message As";
        this.button2.Name = "button2";
        this.button2.ScreenTip = "Archive message in designated place";
        this.button2.ShowImage = true;
        this.button2.SuperTip = "Archives message in designated place";
        this.button2.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.button2_Click);
        // OutlookRibbon
        this.Name = "OutlookRibbon";
        this.RibbonType = resources.GetString("$this.RibbonType");
        this.Tabs.Add(this.tab1);
        this.Load += new Microsoft.Office.Tools.Ribbon.RibbonUIEventHandler(this.OutlookRibbon_Load);
        this.tab1.ResumeLayout(false);
        this.tab1.PerformLayout();
        this.group1.ResumeLayout(false);
        this.group1.PerformLayout();

EDIT 2:

All of a sudden every single addin a make even blank ones in VS cause the errror Ribbon_GetDCVisible say Exception occurred while calling the function GetVisisble. Not sure why, but I turned on show UI errors so maybe this is greying them out? Not sure though because it is happening with every single addin. Even brand new blank ones.

It is a good bit of code. Not sure what parts to show exactly. The only part of code that should run on startup is the normal VSTO addin code and some stuff being added to a dict. I suppose I could post the properties for the ribbon elements. – ss7 May 17, 2015 at 0:05 Looks fine, weird how it works for one button but adding the second button is hidden. I have a couple of suggestions. a) Turn on the logging, my 7th point here and b) try putting the button on a different tab and see if that works to narrow down on the problem domain, try specifying the button names before .group1.Items.Add(this.button1);, try making the buttons with XML or see if you can do it that way: stackoverflow.com/questions/17216199/… – Jeremy Thompson May 17, 2015 at 1:09 Will give those a try and report back, thanks. It is very odd that adding a second button has this affect, the only other things I added are 2 forms, but they are pretty basic and arent called during startup so it shouldnt matter – ss7 May 17, 2015 at 6:05 As for your 7th point in that answer, I just set those environment variables? And where do the VSTO log alerts appear? – ss7 May 17, 2015 at 7:00

The greyed buttons mean that your custom UI is disabled. Most probably you got an error in the markup or your code fires exceptions. Office applications disable add-ins that behave unexpectedly.

I have got a bunch of questions to the initial post, so decided to publish them as an answer as well. It will be hard to recognize them all as a comment. And any of them can lead to the resolution of the issue.

What XML markup do you have so far? Did you try to extract it from the ribbon designer?

Do you get any UI error in Outlook after adding another buttons? See How to: Show Add-in User Interface Errors for more information.

What exception do you have in the getVisible callback? Did you try to debug the code?

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.