Hi,
How do I set up events for Word / C#? That is, something like "display message on double click" is good enough, but I need it to work on any document when this addin is active (not disabled etc.).
I use pretty much everywhere else Interop, but if Tools is required, then Tools is ok too.
I have a start here:
Code:
namespace WordAddIn1
{
public partial class ThisAddIn
{
public event Microsoft.Office.Tools.Word.ClickEventHandler BeforeDoubleClick;
private void DocumentBeforeDoubleClick()
{
Document vstoDoc = Globals.Factory.GetVstoObject(this.Application.ActiveDocument);
vstoDoc.BeforeDoubleClick += new Microsoft.Office.Tools.Word.ClickEventHandler(ThisDocument_BeforeDoubleClick);
}
void ThisDocument_BeforeDoubleClick(object sender, Microsoft.Office.Tools.Word.ClickEventArgs e)
{
Document vstoDoc = Globals.Factory.GetVstoObject(this.Application.ActiveDocument);
System.Windows.Forms.MessageBox.Show(vstoDoc.Name + " was double-clicked.");
}
//and below is then private void ThisAddIn_Startup etc.
This mixes now things up (document-addin and tools-interop) and that's why it isn't working. But how to fix it?