excel ribbon becoming unresponsive

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bob

    excel ribbon becoming unresponsive

    Hi,
    I am trying to create an add-in for Excel using Visual Studio Tools
    for Office. I have added some buttons to ribbon. Upon clicking one,
    I launch another application that interacts with excel. But for some
    reason after doing that the Excel sheet is no longer responsive to
    clicks of the button ribbons. Anyone have any ideas of what could be
    wrong?

    Thanks,
    Bob
  • Frank Munsberg

    #2
    Re: excel ribbon becoming unresponsive

    It is just a wild guess since I haven't done anything with add-in's so
    far. Could it be that that your button starts this other process and
    waits for its completion? If so then my guess is that the thread that
    your button is in may be still waiting for the other process to finish
    hence the blocking UI. Maybe you could try to start the other process
    in a separate thread to get around this, but maybe this also makes
    things too complicated.

    Greets
    Frank

    Comment

    • Bob

      #3
      Re: excel ribbon becoming unresponsive

      On Sep 30, 3:37 am, Frank Munsberg <bufferunder... @gmx.dewrote:
      It is just a wild guess since I haven't done anything with add-in's so
      far. Could it be that that your button starts this other process and
      waits for its completion? If so then my guess is that the thread that
      your button is in may be still waiting for the other process to finish
      hence the blocking UI. Maybe you could try to start the other process
      in a separate thread to get around this, but maybe this also makes
      things too complicated.
      >
      Greets
      Frank

      I think that might be it but when I try to use a ThreadStart to start
      in a different thread the application I am trying to run seems to
      crash. Is this the right way to do it:


      Launcher useForLaunch = new Launcher();

      useForLaunch.ex celObj = excelObj;

      System.Threadin g.Thread oThread = new System.Threadin g.Thread(new
      System.Threadin g.ThreadStart(u seForLaunch.Lau nch));
      oThread.Start() ;

      public class Launcher{

      internal Microsoft.Offic e.Interop.Excel .Application
      excelObj;
      internal void Launch()
      {

      ExternalInterfa ce fInt2 = new ExternalInterfa ce(excelObj);
      }
      }

      Thanks!
      Bob

      Comment

      • Frank Munsberg

        #4
        Re: excel ribbon becoming unresponsive

        Hmm, I have only used the "BackgroundWork er" classes present
        since .Net 2.0.
        The documentation has some pretty good example how to set them up but
        basically its like creating a BackgroundWorke r object, writing at
        least one eventhandler for the DoWork event and one for the
        RunWorkerComple ted event. Any Exception inside the background thread
        will end the thread and you end up inside the RunWorkerComple ted
        handler.


        In your case this would look like
        BackgroundWorke r imyworker = new BackgroundWorke r();
        // then add the event handlers to the DoWork and RunWorkerComple ted
        events and finally call imyworker.RunWo rkerAsync() and off it goes.

        void imyworker_DoWor k(object sender, DoWorkEventArgs e)
        {
        //maybe some other init stuff here
        useForLauncher. Launch();
        }
        void imyworker_RunWo rkerCompleted(o bject sender,
        RunWorkerComple tedEventArgs e)
        {
        if (e.Error != null) // an exception occurred, e.Error contains the
        exception object
        //maybe some other cleanup code, message, log entry etc.
        }

        Maybe the exception that you get tells you what's going wrong

        Greets
        Frank

        Comment

        • Bob

          #5
          Re: excel ribbon becoming unresponsive

          On Oct 1, 2:25 am, Frank Munsberg <bufferunder... @gmx.dewrote:
          Hmm, I have only used the "BackgroundWork er" classes present
          since .Net 2.0.
          The documentation has some pretty good example how to set them up but
          basically its like creating a BackgroundWorke r object, writing at
          least one eventhandler for the DoWork event and one for the
          RunWorkerComple ted event. Any Exception inside the background thread
          will end the thread and you end up inside the RunWorkerComple ted
          handler.
          >
          In your case this would look like
          BackgroundWorke r imyworker = new BackgroundWorke r();
          // then add the event handlers to the DoWork and RunWorkerComple ted
          events and finally call imyworker.RunWo rkerAsync() and off it goes.
          >
                  void imyworker_DoWor k(object sender, DoWorkEventArgs e)
                  {
                          //maybe some other init stuff here
                          useForLauncher. Launch();
                  }
                  void imyworker_RunWo rkerCompleted(o bject sender,
          RunWorkerComple tedEventArgs e)
                  {
                          if (e.Error != null)  // an exceptionoccurr ed, e.Error contains the
          exception object
                          //maybe some other cleanup code, message,log entry etc.
                  }
          >
          Maybe the exception that you get tells you what's going wrong
          >
          Greets
          Frank
          Thanks for the very thoughtful post. I don't think a background
          worker will work because the process I want to start is itself a a
          gui. Not getting an exception in the c#, the excel instance crashes.

          Comment

          Working...