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.
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.)
The problem I have is that calls to ribbon.invalidate are only processed after the macro code has run to completion.
You can see this effect quite easily with a simple test program
Sub test()
ribbon.Invalidate
DoEvents
Sleep (5000)
End Sub
A debug.print in the ribbon "getEnabled" callback will be seen to only be actioned at the end of the 5 second sleep.
Is there any way to force a ribbon.Invalidate to be activated there and then?
:: Edit 1 ::
I have created a small demo workbook to ilustrate the issue: http://www.bodgesoc.org/Button_Demo.xlsm
:: Edit 2 ::
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.
Application.ScreenUpdating = False
Application.ExecuteExcel4Macro "Show.ToolBar(""Ribbon"",False)"
Application.ExecuteExcel4Macro "Show.ToolBar(""Ribbon"",True)"
Application.ScreenUpdating = True