title: VSTO: Why is OfficeRibbon.Context null?
body: <p>I'm developing my first Word 2007 addin, and I've added an OfficeRibbon to my project. In a button-click handler, I'd like a reference to either the current <code>Word.Document</code> or <code>Word.Application</code>.</p>
  
  <p>I'm trying to get a reference via the <code>OfficeRibbon.Context</code> property, which the documentation says should refer to the current <code>Application</code> object. However, it is always <code>null</code>.</p>
  
  <p>Does anyone know either</p>
  
  <p>a) if there is something I need to do to make <code>OfficeRibbon.Context</code> appear correctly populated?<br>
  b) if there is some other way I can get a reference to the Word Application or active Word Document?</p>
  
  <p>Notes:</p>
  
  <ul>
  <li><p>I'm using VS2008 SP1</p></li>
  <li><p>The ribbon looks like it has initialized fine: The ribbon renders correctly in Word; I can step the debugger through both the constructor and the OnLoad members; Button click handlers execute correctly. </p></li>
  <li><p>Here's <a href="http://msdn.microsoft.com/en-us/library/microsoft.office.tools.ribbon.officeribbon.context.aspx?ppud=4" rel="nofollow noreferrer">the online help for this property</a>; </p></li>
  </ul>
  
  <blockquote>
    <p><strong>OfficeRibbon.Context Property</strong></p>
    
    <p><code>C#</code><br>
    <code>public Object Context { get; internal set; }</code></p>
    
    <p>An Object that represents the Inspector window or application instance that is associated with this OfficeRibbon object.   </p>
    
    <p><strong>Remarks</strong></p>
    
    <p>In Outlook, this property refers to the Inspector window in which this OfficeRibbon is displayed.</p>
    
    <p>In Excel, Word, and PowerPoint, this property returns the application instance in which this OfficeRibbon is displayed. </p>
  </blockquote>