I'm trying to create a simple Word add-in. I have created a Word 2010 add-in project with this auto-generated code:
public partial class ThisAddIn
{
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
}
protected override Microsoft.Office.Core.IRibbonExtensibility CreateRibbonExtensibilityObject() {
OwnRibbon ribbon = new OwnRibbon();
//ribbon.DocumentProperty = //get the document here
return ribbon;
}
#region VSTO generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InternalStartup()
{
this.Startup += new System.EventHandler(ThisAddIn_Startup);
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
}
#endregion
}
I've looked at the documentation and I understand how I can add text to the document from this class. What I have however, is a Ribbon (created via new item -> ribbon (visual designer)) with two buttons.
When a button is pressed, I would like to add text to the document. However, this ribbon creates a seperate class:
public partial class OwnRibbon
{
private void OwnRibbon_Load(object sender, RibbonUIEventArgs e)
{
}
private void btnInvoegen_Click(object sender, RibbonControlEventArgs e)
{
}
}
How can I access the document from the click event handler?
Thanks