How to update Status bar from a timer thread

Mar 23, 2012 at 10:44 AM

Hello

I would like to update the Status Bar from a timer but if I simply do

XLApp.StatusBar = "Blah";

it works but when I close Excel, the Excel process remains in the Process list in task manager.

Does anyone know how I can update the status bar in a thread-safe way?

Kind Regards
Jon

Coordinator
Mar 23, 2012 at 4:37 PM

Hi Jon,

You need to be sure you are running on the main Excel thread, and not a worker thread. Easiest might be to use a System.Windows.Timer.Timer, and not one of the (many) other .NET timer classes.

From a worker thread, you'd have to make sure you call Marshal.ReleaseComObject on the Application object and every execution, else there would be an outstanding COM reference keeping Excel alive.

Regards,

Govert

Mar 23, 2012 at 5:41 PM

Hi Govert

Using a System.Windows.Forms.Timer worked like a charm.  I'd previously been using a System.Timers.Timer.

Thanks
Jon