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 Word.Document
or Word.Application
.
I'm trying to get a reference via the OfficeRibbon.Context
property, which the documentation says should refer to the current Application
object. However, it is always null
.
Does anyone know either
a) if there is something I need to do to make OfficeRibbon.Context
appear correctly populated?
b) if there is some other way I can get a reference to the Word Application or active Word Document?
Notes:
I'm using VS2008 SP1
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.
OfficeRibbon.Context Property
C#
public Object Context { get; internal set; }
An Object that represents the Inspector window or application instance that is associated with this OfficeRibbon object.
Remarks
In Outlook, this property refers to the Inspector window in which this OfficeRibbon is displayed.
In Excel, Word, and PowerPoint, this property returns the application instance in which this OfficeRibbon is displayed.