Why does this code fail?

J

JFO

Hi,
I'm getting:
Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))

I believe I do something wrng with the 2. parameter of onkey :(


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Excel = Microsoft.Office.Interop.Excel;
using Office = Microsoft.Office.Core;

namespace ExcelAddIn1
{
public partial class ThisAddIn
{
delegate void testDelegate();
testDelegate t1;

private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
t1 = this.test;
this.Application.OnKey("^G", t1);
//Excel.Range r = this.Application.ActiveCell.DirectDependents;
}

private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{

}

public void test()
{
this.Application.ActiveCell.Value2 = "5";
}
#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
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top