views:

10

answers:

0

I am experiencing a strange problem. I have a custom Ribbon in Excel 2007 (built using RibbonX). Certain tabs in the ribbon are dynamically hidden and dropdowns are dynamically populated. This means that when the use takes certain actions the ribbon must be invalidated so it can be re-drawn.

This works 100% of the time when the user has window focus on Excel. However, if the user clicks my "Refresh" button which takes a couple seconds to grab new data from the server, and they then move to another application (i.e. Excel loses window focus) then when the ribbon tries to re-validate it throws errors.

The only difference I can determine between error and no error is whether the Excel window has focus.

Has anyone ever heard of this or perhaps knows a way to fix it. I can see a couple potential solutions (in order of preference).

  1. Make it so the ribbon does not require Excel window focus.
  2. Somehow bring the window focus back to Excel automatically right before we call Invalidate on the ribbon
  3. Force the user to wait for the Refresh to complete. They cannot change window focus.

Any suggestions are greatly appreciated.