Hi all,
Strange one this. I have the following code built in to one of my add-ins, which enables or disables certain add-in functionality based on the currently active workbook.
I have no problem with the code itself - it works fine.
However... sometimes I accidentally press Alt-Tab instead of Ctrl-Tab when I want to cycle through open workbooks. When this happens I press the Escape key before letting go of the Alt key to abandon the Alt-Tab process and stay in Excel. At this point, if I then immediately press Ctrl+Tab - as I had originally intended - I get the "Code execution has been interrupted: Continue/End/Debug/Cancel" dialogue box coming up.
Anyone know why this happens? It's obviously something to do with the state Excel is left in after the abandoned Alt-Tab action, or perhaps something to do with the "Escape" keypress remaining in some buffer? I don't know. At the moment my add-in is just in development, so it's just a nuisance to me, but I don't want this still going on after I release it.
I have tried Application.EnableCancelKey = xlDisabled, however the break occurs before that property has a chance to be set (i.e. on the "Private Sub App_WorkbookActivate(ByVal Wb As Workbook)" line) and the property gets reset back to xlInterrupt when the code completes and Excel returns to the idle state.
Bookmarks