Let's try again: VBA Code stops randomly

B

BAC

I posted this several days ago but still have not gotten any replies. I've
tried everything I can think of, but can't find a solution...


Xp pro, Office 2003 Pro

I have a routine that begins in Access, moves to Excel, then returns results
from Excel back to Access.

In the middle of the Excel portion of the VBA (the calling Access file has
been closed) the VBA begins and continues to arbitrarily spit out a "Code
execution has been interrupted" dialog box. Selecting Debug turns up a
different code line each time; selecting continue allows the routine to
continue until the next "arbitrary" interruption.

This did not occure when we were running Win 2000 Pro and Office 2000 Pro.
Is this an XP or Office 2003 issue?

I have "googled" the error and found several discussions of this activity,
but have yet to find a clear delineation of its cause or a clear
process/procedure for eliminating it, even tho some real heavy hitters
(MVP's) have addressed this question. Even the KB is really weak in this
area.

Any help would be appreciated -> my users are looking for my head!

BAC
 
J

Jon Peltier

Does the execution jump from one procedure in one application to a different
procedure in another application? This statement makes me cringe: "the
calling Access file has been closed". I think I'd be a little leery of
switching the execution like this. Couldn't you add the proper application
and object references to the Excel based code and port it into the Access
project? This would keep execution in one context only, although it could do
all the same stuff as if it switched around.

- Jon
 
J

Jon Peltier

The changing versions brings another thought to mind. Are there any missing
references in the 2003 version of the program? These often manifest
themselves in seemingly unrelated ways, with perfectly valid statements
causing errors.

- Jon
 
E

Ed

Jon: My macros have done the same thing, and they are all contained with
Excel. My Word macros have done it, too. Most of the time it's only on one
computer. It's a very arbitrary stopping point - never the same place.
Pressing F5 or clicking Continue makes the code move on as if nothing
happened. There are no break points, no errors, no missing objects. Just a
random stop like an old car I used to have. 8>( This is with both
Office 2000 and XP under both Win 2000 and XP.

Ed
 
M

michael.beckinsale

Hi All,

I have experienced similar problems in the past, especially when
running code (Which l know to be OK) on different PC's, operating
systems etc.

This may seen simplistic but l ahve found it is often caused by a
'sticky' Esc or Break key.

Hope this helps,

Regards

Michael Beckinsale
 
B

BAC

The code is like "pages" long and, like I said the stop is pretty much
arbitrary.across procedures and functions
 
B

BAC

Well, then, seems I'm not alone!


Ed said:
Jon: My macros have done the same thing, and they are all contained with
Excel. My Word macros have done it, too. Most of the time it's only on one
computer. It's a very arbitrary stopping point - never the same place.
Pressing F5 or clicking Continue makes the code move on as if nothing
happened. There are no break points, no errors, no missing objects. Just a
random stop like an old car I used to have. 8>( This is with both
Office 2000 and XP under both Win 2000 and XP.

Ed
 
B

BAC

I've vrified all the required references. The Excel portion of the routine is
an automation of a 28 step process that was done a couple years ago, and to
be honest with you, it's a bit convoluted so i really don't want to mess with
it.

It worked fine under Win 2000/Office 2000
 
B

BAC

This can happen when VBA's internal code storage area get screwed up. The
best solution is to Export all code to text files, delete all modules and
all code, then Import the text files. This will cause VBA to purge all its
internal code storage areas and start with a clean slate. Rob Bovey has a
excellent add-in that automates this whole process down to two or three
mouse clicks.

See http://www.appspro.com/Utilities/CodeCleaner.htm

Rob's Code Cleaner is a "must have" add-in for any serious Excel
development.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)
 
B

BAC

This can happen when VBA's internal code storage area get screwed up. The
best solution is to Export all code to text files, delete all modules and
all code, then Import the text files. This will cause VBA to purge all its
internal code storage areas and start with a clean slate. Rob Bovey has a
excellent add-in that automates this whole process down to two or three
mouse clicks.

See http://www.appspro.com/Utilities/CodeCleaner.htm

Rob's Code Cleaner is a "must have" add-in for any serious Excel
development.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)
 
D

david_bn

This can happen when VBA's internalcodestorage area get screwed up. The
best solution is to Export allcodeto text files, delete all modules and
allcode, then Import the text files. This will cause VBA to purge all its
internalcodestorage areas and start with a clean slate. Rob Boveyhasa
excellent add-in that automates this whole process down to two or three
mouse clicks.

Seehttp://www.appspro.com/Utilities/CodeCleaner.htm

Rob'sCodeCleaner is a "must have" add-in for any seriousExcel
development.

--
Cordially,
Chip Pearson
Microsoft MVP -Excel
Pearson Software Consulting, LLCwww.cpearson.com
(email address is on the web site)





- Show quoted text -

Hi,

Mine now stops randomly within the code of the Code Cleaner!!

Can anyone beat that??
 
B

Bob Flanagan

David, lock your project with a password and click on the the option to lock
the project from viewing. It forces the code to keep running. If you are
debugging, you will have to click the run button to get it to start again.
The problem happens sometimes (in addition to corruption) if you have been
in Excel too long, or if you have over 500 or so rows in a module.

Bob Flanagan
Macro Systems
144 Dewberry Drive
Hockessin, Delaware, U.S. 19707

Phone: 302-234-9857, cell 302-584-1771
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel
 
G

Grant Briggs

I've encountered the same problem with the "Code Execution Interrupted"
error. Setting the EnableCancelKey property on the Application object
to xlDisabled in the first line of code (ie."Application.EnableCancelKey
= xlDisabled") seems to have fixed the issue. I don't if this will work
in all cases, but it worked for me. Hope this helps.



*** Sent via Developersdex http://www.developersdex.com ***
 
D

DavidAtCaspian

I have this same problem. It happened on one machine about two weeks ago and
has now spread to three.

The code is not complicated, and has run perectly fine for months
..
I've checked for viruses and spyware, run the code cleaner tool (which
worked last week, but doesn't today)

I haven't come across the application cancel key one before: Surely this is
effectively taking away the capability of breaking into the code with
CTRL-Break?
And if so, seems to indicate that 'something' on these PCs is simulating
this key combination spontaneously -- but only in Excel -- so far, none of my
Access code is suffering.




If I didn't know better I'd say that a recent automatic update might be the
culprit.
 
J

John Keith

I'm having the same problem described by BAC. Random breaks as if a gremlin
were pressing CTRL+BREAK at random intervals. When Debugging the code after
this happens, the yellow box points to random lines of code that are
perfectly fine for execution. The project will complete 100% of the time
just be "continue"ing execution after each random break.

I loaded Rob Bovey's code cleaner and tried it. I got it to work after
enabling the trust for VBA projects... AND "Continue"ing through its code
(the gremlin saw the cleaner code running too and tried to break it)
HOWEVER: the cleaned project still randomly stops execution.

Could there be some excel modules that are corrupt? The code cleaner after
the initial install, immediately started randomly breaking... so the
root-casue of this issue can not be with the VBE-editor's internal code
storage (unless it is being corrupted by a corrupted excel-module that needs
to be re-loaded)

Has anyone been able to solve this?
 
D

DavidAtCaspian

And even worse: Our code rus repeatedly throughout a session - We've
automated a copy/paste routine. When we first start up, the code runs
through. Then is begins to break, then later it breaks all the time. It's not
totally random with us, but breaks somewhere within a loop that is working
down the sheet to find an empty cell. It usually breaks on the 'WEND' line
(but at different rows.) If not then within three lines of it. The work
rounf of Enter-F5 always result in sucessful completion of that cycle.
And as you say John, it lokks EXACTLY like a poltergeist has noticed a bit
of nicely running code and is hitting ctrl-break for us.

We've tried it with or without the source (web based) application running,
we've tried doing the copy/paste manually, all to no avail. - It as if Excel
has decided how many times it is going to run properly during a given
session, and then just gives up.

We have looked at the upgrade history on the machines, and cannot find any
changes that coincide with the start of the problem.

The problem is spreadin just like a disease..........
 
N

NickHK

Assuming you tried all other normal fixes, what happens if you run the code
from a VBScript instead of from within VBA ?
It will involve a slight re-write, but the basic code will be the same.
No idea if it will make a difference, but if you are out of other ideas ...

NickHK
 
J

John Keith

my VB scripts don't have any problem.

the excel applications are heavily rooted in the excel object. The
applications use specialized command bars and drop downs for choosing
execution criteria and are genrated on opening based on other sources of
data. The apps that are the most basic (although still producing,
essentially a formatted report) would work from script, and I do have some
that extract data via ADO from SQL-Server data. But the whole point of using
excel-VBA was to put the output into a form that was "pretty" to the end-user.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top