Montag, 7. Januar 2013

ThisRibbonCollection' does not contain a definition for 'GetRibbon'....

If you see this error, don't panic, the solution is rather simple:

To make matters easier for you, Office AddIns have a partial class "ThisRibbonCollection" which is automatically used to define your Ribbon Control as the MainRibbonControl of the application. This might seem, after the creation and a first run rather as magic, unless of course, you want to have all your application controls in a separate folder and therefore separate namespace from ThisAddIn.cs. (thx for the hint to http://qa.social.msdn.microsoft.com/Forums/en-SG/vsto/thread/3b117e7a-e3d5-4f10-8262-358b04494230)

However there is also a solution to this, allowing you to keep your RibbonControl in a separated folder and namespace:

Open <RibbonControl>Designer.cs

Go to the end of the file where you see partial class ThisRibbonCollection

Create at the end of the file a new namespace section, with the root-namespace of your AddIn

Move the class into the new namespace

Since you are in a different namespace now, don't forget to add the necessary usings