Why do I get a message stating "Code execution has been interrupted" and how do I fix it?

Hello,

I have an excel file with a block of VB code attached to it and whenever I try to run it I get a message stating "code execution has been interrupted". When I hit the continue button then the code carrys on until the next seemingly arbitrary point at which the code stops and the message appears again. Could someone let me know why this is happening and how I can ensure the code runs continously?

Thanks,

f19l
f19lAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MajorBigDealCommented:
Try turning off macro security
0
f19lAuthor Commented:
Macro security is currently set to low. Other files with embedded macros run fine.
0
owitteCommented:
check the vba code for errors by running it step by step from the code editor. Usually this happens if there're unhandled errors.

Regards
Oliver
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

f19lAuthor Commented:
I have tried that but the strange thing is that when the code stops and I continue running it step-by-step, it works fine.
0
owitteCommented:
can you post the piece of code where it stops (+/- about 10 lines) and give some info about the context?
0
HooKooDooKuCommented:
Based on a quick Google search on "Code execution has been interrupted", it looks like this is an issue that has been around for a while.  The 1st link I come up with seems to describe your situation exactly.  There solution was to add "Application.EnableCancelKey = xlDisabled" at the start of the macro.

http://www.mymindleaks.com/blog/article/fix-for-code-execution-has-been-interrupted-in-excel-vba-macros.html

 
Looks like the issue has also been discussed on the microsoft web site as well:
http://social.msdn.microsoft.com/Forums/en-US/isvvba/thread/3a5cf3ab-fe20-45d5-912c-bbb249b1e391/
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MajorBigDealCommented:
I agree with owitte, if you post some code we can try to replicate it.
0
f19lAuthor Commented:
Thanks all but HooKooDooKu has found the solution for me.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.