title: Excel VBA Ribbon getEnabled not called when code running
body: <p>I have an Excel VBA macro that runs for a long time (potentially for days, it performs data acquisition). It was originally written for Excel 2003 and has custom toolbars and menus. 
  I recently updated it to use a ribbon interface using RibbonXML. </p>
  
  <p>When the macro is running I want to disable some interface elements (such as "start test"), and enable others (such as the "stop test" button.)</p>
  
  <p>The problem I have is that calls to ribbon.invalidate are only processed <em>after</em> the macro code has run to completion. </p>
  
  <p>You can see this effect quite easily with a simple test program</p>
  
  <pre><code>Sub test()
  
  ribbon.Invalidate
  DoEvents
  Sleep (5000)
  
  End Sub
  </code></pre>
  
  <p>A debug.print in the ribbon "getEnabled" callback will be seen to only be actioned at the end of the 5 second sleep. </p>
  
  <p>Is there any way to force a ribbon.Invalidate to be activated there and then? </p>
  
  <p>:: Edit 1 ::</p>
  
  <p>I have created a small demo workbook to ilustrate the issue:
  <a href="http://www.bodgesoc.org/Button_Demo.xlsm" rel="nofollow">http://www.bodgesoc.org/Button_Demo.xlsm</a></p>
  
  <p>:: Edit 2 ::</p>
  
  <p>A member of a different forum found a solution, though it is a slightly ugly one. 
  I guess this can now be marked as "answered" but a more elegant solution would be appreciated. </p>
  
  <pre><code>Application.ScreenUpdating = False
  Application.ExecuteExcel4Macro "Show.ToolBar(""Ribbon"",False)"
  Application.ExecuteExcel4Macro "Show.ToolBar(""Ribbon"",True)"
  Application.ScreenUpdating = True
  </code></pre>