Here's old problem that nobody has solved yet. It's a long message because it's omplicated.
For the past few years (2002-2006) I have experienced this problem, and so have many other people based on searches across the web.
I write some VBA in Excel 2002 or 2003, in windows XP pro.
After a while, a few hours maybe, the code just stops and shows the error "Code execution has been interrupted", with the 'continue, end, debug' options. Click 'continue' and the code moves along, but then stops later at some other point with the same message.
I have experienced this with more than a dozen projects, ranging from simple apps to complex apps. It occurs randomly and is not related to any specific VBA code.
It happens frequently on one of my PC's, which is a newer XP pro, and a few others I have tried, but does not happen on other PC's that have the same versions of Excel and XP pro.
Many times I have searched the web for answers, and have found many people with the same problem.
I am certain it is caused by some process or event, within Excel or the O/S that is simulating a 'Ctrl-Break'. I have used the following code to verify this:
-----------------------
Sub Test_Interupt()
On Error GoTo errorhandler
'---
'-- trap the Cancel key with an error handler
Application.EnableCancelKey = xlErrorHandler '<--
'-- Do some processing, calculations, worksheet actions, etc
'-- simple or complex, it doesn't make any difference.
'-- A 'cancel' key is being applied here by a process or external event
'-- and it goes to the ErrorHandler
Done:
MsgBox "DONE"
Exit Sub
errorhandler:
If Err.Number = 18 Then Resume Next '<-- user interupted ?
MsgBox "Error: " & Err.Number & " - " & Err.Description, vbCritical
End Sub
-----------------------
I am a seasoned software developer with extensive experience in VB, VB.Net, OOP, and VBA. Please do not ask for samples of code, I assure you there are no bugs in my code.
There has been speculation that it is related to corrupt files (DLL's, OCX's, etc), but nobody has identifed what the file(s) are.
There is speculation that it's caused by XP pro service packs, but this has also never been confirmed.
There has been speculation that Virus software is interupting the VBA, but I have tested it with different virus software and it makes no difference; it runs ok on one PC but not on another with exactly the same configuration.
The only upside is this; so far it seems related to and limited VBA development. Turn on the PC, do some extensive VBA development for a while and the problem starts. Turn off the PC, restart and it works ok for a while. However, if you have compiled the app without any interruptions that it can be run by a user without any problems.
It appears to be limited to VBA development - something is screwing up the memory or system process.
Your solutions are greatly appreciated
-- Larry Trudelle --
For the past few years (2002-2006) I have experienced this problem, and so have many other people based on searches across the web.
I write some VBA in Excel 2002 or 2003, in windows XP pro.
After a while, a few hours maybe, the code just stops and shows the error "Code execution has been interrupted", with the 'continue, end, debug' options. Click 'continue' and the code moves along, but then stops later at some other point with the same message.
I have experienced this with more than a dozen projects, ranging from simple apps to complex apps. It occurs randomly and is not related to any specific VBA code.
It happens frequently on one of my PC's, which is a newer XP pro, and a few others I have tried, but does not happen on other PC's that have the same versions of Excel and XP pro.
Many times I have searched the web for answers, and have found many people with the same problem.
I am certain it is caused by some process or event, within Excel or the O/S that is simulating a 'Ctrl-Break'. I have used the following code to verify this:
-----------------------
Sub Test_Interupt()
On Error GoTo errorhandler
'---
'-- trap the Cancel key with an error handler
Application.EnableCancelKey = xlErrorHandler '<--
'-- Do some processing, calculations, worksheet actions, etc
'-- simple or complex, it doesn't make any difference.
'-- A 'cancel' key is being applied here by a process or external event
'-- and it goes to the ErrorHandler
Done:
MsgBox "DONE"
Exit Sub
errorhandler:
If Err.Number = 18 Then Resume Next '<-- user interupted ?
MsgBox "Error: " & Err.Number & " - " & Err.Description, vbCritical
End Sub
-----------------------
I am a seasoned software developer with extensive experience in VB, VB.Net, OOP, and VBA. Please do not ask for samples of code, I assure you there are no bugs in my code.
There has been speculation that it is related to corrupt files (DLL's, OCX's, etc), but nobody has identifed what the file(s) are.
There is speculation that it's caused by XP pro service packs, but this has also never been confirmed.
There has been speculation that Virus software is interupting the VBA, but I have tested it with different virus software and it makes no difference; it runs ok on one PC but not on another with exactly the same configuration.
The only upside is this; so far it seems related to and limited VBA development. Turn on the PC, do some extensive VBA development for a while and the problem starts. Turn off the PC, restart and it works ok for a while. However, if you have compiled the app without any interruptions that it can be run by a user without any problems.
It appears to be limited to VBA development - something is screwing up the memory or system process.
Your solutions are greatly appreciated
-- Larry Trudelle --