Not Showing Ribbon Tab

Jan 13, 2011 at 9:13 PM

The following code worked with no issues... for about 5 minutes. After I closed Excel and opened it backup the ribbon tab I created no longer shows up.
Below is the simple code I am using to test... The MessageBox that shows "HEY" does appear... just no ribbon tab gets displayed.

[ComVisible(true)]
public class EFRRibon : ExcelRibbon
{
	public override string GetCustomUI(string uiName)
	{
		System.Windows.Forms.MessageBox.Show("HEY");

		return
		@"<customUI xmlns='http://schemas.microsoft.com/office/2009/07/customui'>
				<ribbon>
				<tabs>
					<tab idMso='Tab1' label='EManager FR'>
					<group id='Group1' label='Log'>
						<button id='Button1' label='View Files' getImage='GetRibbonControlImage' size='Large' onAction='OnButtonPressed'/>
					</group>
					</tab>
				</tabs>
				</ribbon>
			</customUI>";
	}

	public void OnButtonPressed(IRibbonControl control)
	{
		switch (control.Id)
		{
			case "EFRViewLogFiles":
				if (LogSettings.LogFileDirectory.Exists == true)
				{
					System.Diagnostics.Process.Start(LogSettings.LogFileDirectory.FullName);
				}
				else
				{
					System.Windows.Forms.MessageBox.Show("Log File Directory does not exist.");
				}
				break;
			default:
				break;
		}
	}

	public System.Drawing.Image GetRibbonControlImage(IRibbonControl control)
	{
		System.Windows.Forms.MessageBox.Show("GetRibbonControlImage");
		switch (control.Id)
		{
			case "EFRViewLogFiles":
				return Resources.Images.Server_Log;
			default:
				break;
		}

		return null;
	}

}
Coordinator
Jan 14, 2011 at 7:14 AM

Hi Michael,

My first thought is that showing the MessageBox in the GetCustomUI method is very dangerous. Try to just remove that line and check whether it works. The MessageBoxes elsewhere should be fine - you just can't do any UI stuff in the GetCustonUI method itself.

Also, Excel might have marked your add-in as problematic, so you might like to try it after renaming your addin (as a test just rename the .xll and the class name) and test again.

Let me know what you find. If this still doesn't work, I'm happy to have a closer look over the weekend.

Regards,

Govert

Jan 14, 2011 at 2:46 PM

No luck on removing the MessageBox... I only included it to make certain that GetCustomUI waas being called.
I have completely removed the addin from Excel and "reinstalled" it... still no luck.

Michael

Coordinator
Jan 14, 2011 at 5:48 PM

Do the samples in the Excel-DNA distribution still work on your Excel?

Jan 14, 2011 at 5:56 PM

Just tried that and they work.

On a side-note... the Description parameter for the ExcelFunction attribute seems to have a max length... if the string length exceeds some number the function will no longer be available in Excel... not certain what the length is.

Michael

Jan 18, 2011 at 4:05 PM

Any ideas? This is really stumping me...

 

Michael

Coordinator
Jan 19, 2011 at 2:45 PM
Edited Jan 19, 2011 at 2:48 PM

Hi Michael,

Maybe you can start with the working samples and slowly change them to work like your desired Ribbon, and see where along the way it breaks.

I notice in the snippet you posted that the buttonId doesn't match that in your handler. But I presume this is not the issue, since your Ribbon doesn't even display.

Have you tried with a renamed class and renamed .xll file?

If this doesn't work, you might like to post to the Google group (http://groups.google.com/group/exceldna) to see if anyone else has encounters problems (or had success?) with the Ribbon features. I think the Google group is followed a bit more actively than this discussions page.

-Govert

Coordinator
Jan 21, 2011 at 2:36 PM

Found it!

1. I see you have an idMso= attribute in your tab tag, which refers to ids of the built-in tabs - you should probably use id=.

2. And, you can't say  size='Large' , you need  size='large' . The mixed case makes the whole Ribbon not load. How irritating is that? 

(I see that you are using the Excel 2010 schema in your example. This Ribbon will only show under Excel 2010. For a Ribbon that would show under both Excel 2007 and Excel 2010 you'd put 

<customUI xmlns='http://schemas.microsoft.com/office/2006/01/customui'>).

This works for me on Excel 2007:

<customUI xmlns='http://schemas.microsoft.com/office/2006/01/customui'>
   <ribbon>
      <tabs>
         <tab id='Tab1' label='EManager FR 4'>
            <group id='Groupx1' label='Log'>
                  <button id='EFRViewLogFiles' label='View Files' getImage='GetRibbonControlImage' size='large' onAction='OnButtonPressed'/>
            </group>
         </tab>
      </tabs>
   </ribbon>
</customUI>

-Govert

Jan 25, 2011 at 3:56 AM

THANK YOU!!!! It worked like a charm!
I will be verying all the xml attributes now with the ribbon schema defs... because the 'Large' was messing me up.

As always I appreciate the help!

Michael

Jun 12, 2012 at 3:09 PM

Hi,

Just so you know, if your addin is considered as problematic by Excel because of a lot of unexpected exceptions, you can remove it from quarantine by going into Excel options, add-ins tab, Manage and select "Disabled Items", then Go and select you add-in and re-enable it, and you're good to go :)

Franck.