tags:

views:

41

answers:

1

I have a workbook project(VSTO 2007). What I want to do is that I want to execute some method by pressing CTRL+R.

What I have done is the below

private void InternalStartup()
 {
   this.btnProcessTable.Click += new System.EventHandler(this.btnProcessTable_Click);

   Globals.ThisWorkbook.Application.OnKey("^r", "test");
 }

And the test method is

private void test()
{
            MessageBox.Show("Just a test");
}

Next when I ran the application and press CTRL + R , I encounter the below message

Cannot run the macro test. The macro maynot be available in this workbook or all macro's may be disable

I check that all the macros are enable and the funciton (test) is in the same workbook.

Any idea of how to fix the issue.

Thanks

A: 

It seems, that you need to declare your function as public. Having a private function will hide it from the overlying system somehow.

public void test()
{
            MessageBox.Show("Just a test");
}
froeschli
I already tried with that.. and more over both are in the same class.. So the access modifier is not an issue
priyanka.sarkar_2
Well, then I can't help you out. Sorry to have put your hopes up, with an answer, you already tried.
froeschli