View Full Version : "Code Execution Has Been Interrupted"


XLEAccessGuru
10-08-2007, 08:13 AM
Hi Everyone!

In Excel VBA, and ONLY on my laptop at work, I get run-time messages that say "Code Execution Has Been Interrupted" just as if I hit CTRL + BREAK. I have NOT hit break and this only happens on my laptop at work. The same exact program will run perfectly on any other machine but just seems to stop as if I manually interrupted it on the laptop. It will stop on something stupid like:

Sheets("MainMenu").Select

I have been struggling with this for MONTHS. Several of my automated reports can't run overnight outside of business hours like they need to because of this.

If anyone can save me here, I will be eternally grateful! I've tried EVERYTHING.

Remember - this only happens on my laptop. If I run the any of these Excel automation programs on ANY other machine, it runs all the way through without being interrupted.

Awaiting my Savior,
XLEAccessGuru

unmarkedhelicopter
10-08-2007, 09:47 AM
Try using Worksheets("MainMenu").Select or ActiveWorkbook.Worksheets("MainMenu").Select or ThisWorkBook.Worksheets("MainMenu").Select (depending on which you feel is most applicable and see if you get the same result.

Tanner65
01-09-2008, 11:53 AM
I've having a similar issue, the code worked find in the past, but about a week ago, it started getting angry with me.

It seems to be happening after almost all of my SQL queries which are restricted to a single module. Below is some code. The queries are completing correctly and updating the worksheet, but I'm getting the same window "Code Execution Has Been Interrupted."

So far I've tried:
Copying the modules to text files, removing the modules and pasting the code into new modules with the same names as to not have to recode.
Uninstalling/Reinstalling Microsoft Office XP which fixed the problem for two days
Codecleaner v4.5 and codecleaner v5.0

I don't have the ability nor anyone elses time to try this on someone elses computer, otherwise I would.


Sub qrySOMaster(strCell As String, iSOrder As String)
Range(strCell).Select
With Selection.QueryTable
.Connection = ******
.Sql = ("SELECT ""SO Master"".ORDNUM_27, ""SO Master"".CUSTPO_27, ""SO Master"".TERMS_27, ""SO Master"".SHPVIA_27, ""SO Master"".FOB_27, ""SO Master"".ORDID_27, ""SO Master"".REP1_27, ""SO Master"".ORDDTE_27, ""SO Master"".CUSTID_27, ""SO Master"".NAME_27, ""SO Master"".ADDR1_27, ""SO Master"".ADDR2_27, ""SO Master"".ADDR3_27, ""SO Master"".CITY_27, ""SO Master"".STATE_27, ""SO Master"".ZIPCD_27, ""SO Master"".CNTRY_27, ""SO Master"".COMNT3_27 FROM ""SO Master"" ""SO Master"" WHERE (""SO Master"".ORDNUM_27='" & iSOrder & "')")
.Refresh False
End With '<------Stops here every time
End Sub


iSorder is the Sales Order number entered by the user.


I can't find anyway to fix it, please help!


Edit:
After pressing F5 and "c" through it, I've found that it also errors on my clear button.

Private Sub ClearButton_Click()
Application.ScreenUpdating = False
modCleaning.ClearData "Clear"
Application.ScreenUpdating = True
End Sub '<----Error's here

unmarkedhelicopter
01-09-2008, 12:28 PM
Thread Hijack

Tanner65
01-09-2008, 12:29 PM
Thread Hijack
Well, I know how much people don't like to have a second thread made about something that's exactly the same...

Wouldn't consider it a hijack more like a piggy back :D

Tanner65
01-11-2008, 07:42 AM
So, I've come across a way to fix the problem.

When it starts doing that, if I clear all breakpoints and save, then restart my computer it'll run fine for awhile.

Must be some windows cache thing or something of that sort that gets bogged down.


Hope this helps someone.