I am following this MSDN walk-through: https://msdn.microsoft.com/en-us/library/5eef9s6f.aspx
But I get an error for the line:
Document extendedDocument = Globals.Factory.GetVstoObject(this.Application.ActiveDocument);
The error is a red underline on Application and reads:
'MyRibionAddin.MyRibbon does not contain a definition for 'Application' and no extension method 'Application' accepting a first argument of type 'MyRibionAddIn.MyRibbon' could be found ( are you missing a using directive or an assembly reference?)
Replaced with
Document extendedDocument = Globals.Factory.GetVstoObject(Globals.ThisAddIn.Application.ActiveDocument);
and it works