Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. .net event in Excel

.net event in Excel

Scheduled Pinned Locked Moved C#
csharptutorialquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zecodela
    wrote on last edited by
    #1

    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

    D 1 Reply Last reply
    0
    • Z zecodela

      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

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      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...

      Z 1 Reply Last reply
      0
      • D Dave Kreskowiak

        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...

        Z Offline
        Z Offline
        zecodela
        wrote on last edited by
        #3

        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();
        

        }

        D 1 Reply Last reply
        0
        • Z zecodela

          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();
          

          }

          D Offline
          D Offline
          dojohansen
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups