.net event in Excel
-
Hi all, Any idea how to handle an C# event in a Excel? eg. invoke Excel action with a C# timer event. (I can article "C# handle Excel's event" but not "C# event in Excel") thank you! Jim
You're going to have to explain what you mean and which "event" and how this code is setup. Are you using the Excel Object Model in your C# code?? Or did you write an application in C$ that Excel is running through a Shell statement, or something similar??
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008
But no longer in 2009... -
You're going to have to explain what you mean and which "event" and how this code is setup. Are you using the Excel Object Model in your C# code?? Or did you write an application in C$ that Excel is running through a Shell statement, or something similar??
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008
But no longer in 2009...I am not sure about the Excel Object Model. I want to have a C# library I can call a C# function, which i have done with help of below article. http://blogs.msdn.com/eric\_carter/archive/2004/12/01/273127.aspx I also want to have setup callback, event in the C# space and i can get the callback/event inside Excel. eg. i have an event like below, i can get the event with AlarmEventHandler. I just want to have such event happening in Excel. (below code copied from msdn)
public class AlarmClock
{
public event AlarmEventHandler Alarm;protected virtual void OnAlarm(AlarmEventArgs e) { if (Alarm != null) { // Invokes the delegates. Alarm(this, e); } }
}
public static void Main (string[] args)
{
// Instantiates the event receiver.
WakeMeUp w= new WakeMeUp();// Instantiates the event source. AlarmClock clock = new AlarmClock(); // I want to able to get this event inside Excel VBA space. clock.Alarm += new AlarmEventHandler(w.AlarmRang); clock.Start();
}
-
I am not sure about the Excel Object Model. I want to have a C# library I can call a C# function, which i have done with help of below article. http://blogs.msdn.com/eric\_carter/archive/2004/12/01/273127.aspx I also want to have setup callback, event in the C# space and i can get the callback/event inside Excel. eg. i have an event like below, i can get the event with AlarmEventHandler. I just want to have such event happening in Excel. (below code copied from msdn)
public class AlarmClock
{
public event AlarmEventHandler Alarm;protected virtual void OnAlarm(AlarmEventArgs e) { if (Alarm != null) { // Invokes the delegates. Alarm(this, e); } }
}
public static void Main (string[] args)
{
// Instantiates the event receiver.
WakeMeUp w= new WakeMeUp();// Instantiates the event source. AlarmClock clock = new AlarmClock(); // I want to able to get this event inside Excel VBA space. clock.Alarm += new AlarmEventHandler(w.AlarmRang); clock.Start();
}
Yes, you can do this. Go read MSDN articles about Office Interop and you'll soon be able to do this and much more - as long as your code only needs to work with the later incarnations of Office.