If I am debugging (in this case a Visual Studio assembly called by Excel) and the code updates the Excel worksheet, how do I get Excel to redraw the current sheet / window whilst paused in the debugger?
If you are calling Excel cross-process (e.g. via Automation) then Excel should automatically show any changes as the calls are made, unless you set xlApp.ScreenUpdating = False
. If this is the case, then you would probably be best off to use a conditional to not set xlApp.ScreenUpdating = False
if running in Debug mode when you have break points set up. Otherwise, you'd have to set xlApp.ScreenUpdating = True
from some other process (using GetObject()
, or something similar, so that you can grab the same Excel Application instance).
However, if your code is being called in-process (for example, if your code is running as an add-in) then your code is being triggered via a hot-key combination, CommandBar button, Ribbon control callback or the like. In this case, Excel is single-threaded and your code is halting all Excel execution. The only thing I could think of, in this case, would be to use "edit and continue", adding the line xlApp.ScreenUpdating = True
and then stepping into this next line. (Remember to remove this line afterward, though!)
If you are not using xlApp.ScreenUpdating = False
, then I don't really know what your issue is, and you'd have to provide more details on your code...