Word - "Code Execution has been Interrupted" message appears randomly

Asked By ksurvel
29-May-07 09:48 AM
I've encountered this in various versions of Word (2002, 2003, and 2007) when
running macros.

When the problem occurs, running any macro, no matter how simple, will cause
the message "Code execution has been interrupted" to appear, as if you had
pressed CTRL-BREAK. It will continue to occur throughout the macro, at random
points. If you click "Continue," it will run a little bit more, then break
again. If you click "Break," you will see that execution has stopped on some
random line. I've made several test macros with stuff like "if 1 = 1" that
(presumably) can't fail, yet it will break on those lines as well.

I have tried "clear all breakpoints" in the VBA editor.

I've tried the usual troubleshooting methods: deleting normal.dot, removing
any add-ins, running a detect & repair, etc. No joy with any of them.

I've had limited success with rebooting the computer - but it is not a
sure-fire fix, as it will resolve the problem on some machines but not
others. I suspect that it is just coincidental that rebooting and the problem
going away happen at the same time - or there may be something else going on
that I can't localize.

I cannot cause the problem to occur on demand (I know this makes it really,
really hard to troubleshoot.)

I've exhausted all the troubleshooting steps I can think of. Does anyone
have any suggestions?
MVP
(1)
CAPSsympatico
(1)
JmarcilREMOVE
(1)
CaTHISTOO
(1)
SPAMikleAThotmailD
(1)
ThisDocument
(1)
Excel
(1)
EnableCancelKey
(1)
  Jean-Guy Marcil replied...
29-May-07 11:51 AM
ksurvell was telling us:
ksurvell nous racontait que :


Where are those macros stored? (Which template)

--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org
  ksurvel replied...
29-May-07 12:06 PM
The errors occur regardless of where the macros are stored; in normal.dot,
in the currently-open document, in an add-in.
  Perry replied...
29-May-07 12:41 PM
Time to do some cleanups in both templates and VBA projects
http://word.mvps.org/FAQs/MacrosVBA/TemplateBloat.htm

and google around on VBA Code Cleaners to get you tools
to clean up VBA code.

--
Krgrds,
Perry

System:
Vista/Office Ultimate
VS2005/VSTO2005 SE
  ksurvel replied...
29-May-07 01:02 PM
I've read this (and other) articles on the MVPS website before. I've had no
luck with "code cleaners." The problem occurs even if I delete the
templates & add-ins, and then create a new, blank Word document, put a few
lines of macro code in, and try to run it. In that case, what would I clean -
the unsaved blank document with the new code in it?
  Jean-Guy Marcil replied...
29-May-07 01:26 PM
ksurvell was telling us:
ksurvell nous racontait que :


And when you performed that blank document test, had you ensured that no
other third-party add-in(s) was(were) also running at the time you executed
the test?

--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org
  ksurvel replied...
29-May-07 01:48 PM
Yes. All add-ins were removed and normal.dot had just been re-created (by
Word).
  Jean-Guy Marcil replied...
29-May-07 03:09 PM
ksurvell was telling us:
ksurvell nous racontait que :



sure-fire fix, as it will resolve the problem on some machines but not
others."

Have you tested these new templates created while only normal.dot was active
(and not other add-ins at all) on other machines?
Did you still get the same error message?


--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org
  ksurvel replied...
29-May-07 03:30 PM
I'm not necessarily creating templates here - in fact, in most cases I am not
creating templates at all. I'm saving into what is now called a "macro
enabled document." So, they are just documents that contain macros - not
templates or anything special.

On one computer, if the problem occurs, I shut down completely & reboot, and
when I try to run macros again, the problem does not occur. This happens
*without* having to clear normal.dot or remove any of the (several) add-ins
that are on that computer. However, on others, even if I remove all add-ins,
delete normal.dot, and then reboot, the problem will re-occur even if I just
open a blank Word document and write a simple macro.
  Jean-Guy Marcil replied...
29-May-07 03:49 PM
ksurvell was telling us:
ksurvell nous racontait que :


Does this means that this behaviour is observable only on Word 2007?


You have mentioned observing this behaviour on many computers.
Are these computers all part of the same network, hence all configured in
the same way?
Or are these computers all totally unrelated machines, each configured in a
different and unique way across many Word versions?

--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org
  ksurvel replied...
29-May-07 04:33 PM
No, the behavior has been observed in both Word 2003 and Word 2007, with
both old-style Word 97-2003 format documents, as well as Word 2007 "macro
enabled documents" (*.docm).


They are on unrelated machines - the only common factor is that they are
using macros in some way.
  Jean-Guy Marcil replied...
29-May-07 10:16 PM
ksurvell was telling us:
ksurvell nous racontait que :


Then I do not know what to say anymore...

If you observed this error message on unrelated machines, using various Word
versions, even after uninstalling all add-ins and recreating Normal.dot...
Then there is some black spell that was cast on you... I have never seen
this message regularly, only at occasion when  I did something wrong or had
a corrupt template, and I have never heard of such a situation where one
individual witnesses the same error message on unrelated machines....

Or else, there is something else under the hood you haven't noticed or
forgot to tell us...

--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org
  Russ replied...
30-May-07 02:17 AM
Are we overlooking the obvious answer, it's a macro virus?
It may be corrupting the Word application to self impose a disable of
running macros.
Is the heritage of the macros being used known?
Are they stored in the "ThisDocument" module or was a new module other than
the "ThisDocument" module used to store the macros in the document?


--
Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID
  Jean-Guy Marcil replied...
30-May-07 04:21 AM
Russ was telling us:
Russ nous racontait que :


I doubt it, unless he is not telling the whole story.
See a few replies up the thread when he stated:

luck with "code cleaners." The problem occurs even if I delete the
templates & add-ins, and then create a new, blank Word document, put a few
lines of macro code in, and try to run it. In that case, what would I
clean -
the unsaved blank document with the new code in it?"


--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org
  Russ replied...
30-May-07 06:25 AM
Another one of his statements was:

The only common factors among his various machines and various versions of
Word would appear to be the running of macros and his network, if they are
connected, which makes it seem like a virus. Maybe a anti-virus program
could fix it, but all Word apps or certain Word .dlls on his network might
be corrupted.
On networks, is there one master watchdog (Policy Service?) that handles
macro security?
Maybe that watchdog, if it exists, is corrupted because that would also
explain multiple versions and machines having the same problem.


--
Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID
  ksurvel replied...
30-May-07 12:00 PM
I suspected a macro virus as well, but the systems are not physically
connected, and they use different anti-virus programs (I've seen the symptoms
on computers running Norton, McAffee, and AVG).

The only commonality is that the computers in question are opening a
document that contains macros. (Actually, a set of documents that all contain
macros, in both ThisDocument and in modules.)

I've run code cleaners on the documents themselves, wondering if they've
become corrupted somehow, but I cannot tie it down to one document - and once
the problem occurs, it occurs no matter what document is opened. And again,
I've deleted normal.dot, and removed all add-ins, so... ?
  Jean-Guy Marcil replied...
30-May-07 12:01 PM
Russ was telling us:
Russ nous racontait que :


Ah, yes, he did not write that all the different computers he had tested
where on the same network, but that is definitely a possibility.

--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org
  paolo ruffini replied...
21-Jan-09 04:47 PM
We have observed this behavior in MS Excel 2003 as well.  Macros break in random spots for no apparent reasons.
  wanderez ici replied to ksurvel
13-Apr-10 04:43 AM
I re-installed code and restarted the system. Now the macro is running without any hitch.
  Suresh babu replied to wanderez ici
17-Apr-10 01:46 AM
Put this as the first statement in your code:

Application.EnableCancelKey = xlDisabled (For Excel)

Application.EnableCancelKey = wdCancelDisabled (For Word)

Now u won't get the interruption message.
  Andrew Walsh replied to Suresh babu
29-Jun-10 09:30 AM
Had the same problem on every macro and template, tried everything from re-installing office, updating the service pack, renaming the profile but nothing worked.



The fix for this error was a new keyboard.



Try it!
  Don replied to ksurvel
06-Dec-10 04:56 PM
Application.EnableCancelKey = xlDisabled works HOWEVER if your macro is long there is a chance it will automatically enable itself while executing the code.  So obviously in this case you'll have to put perhaps several "Application.EnableCancelKey = xlDisabled" commands in your macro to allow it to run smoothly.  But I don't like these solutions.  There must be a Windows OS API that will do a better job of disabling the cancel keys.  After all it's probably being automatically executed by the OS as a security measure.  Any know?
help
certainly. What part exactly are you having difficulty with? - - Salut! _ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ Jean-Guy Marcil - Word MVP jmarcilREMOVE@CAPSsympatico.caTHISTOO Word MVP site: http: / / www.word.mvps.org Word VBA Beginners Discussions Userform (1) Excel (1) Intersecting sure you have plenty of time ahead of you! - - Salut! _ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ Jean-Guy Marcil - Word MVP jmarcilREMOVE@CAPSsympatico.caTHISTOO Word MVP site: http: / / www.word.mvps.org Hi Jean-Guy - I appreciate the difficulity of doing
how do I get an office assistant? Word Word VBA Discussions CAPSsympatico (1) JmarcilREMOVE (1) CaTHISTOO (1) MVP (1) _ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ (1) Helps (1) Salut (1) Paper (1) Putting an add in the paper often helps. - - Salut! _ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ Jean-Guy Marcil - Word MVP jmarcilREMOVE@CAPSsympatico.caTHISTOO Word MVP site: http: / / www.word.mvps.org keywords: how, do, I, get, an, office, assistant?
we see the full relevant code instead of excerpts? - - Salut! _ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ Jean-Guy Marcil - Word MVP jmarcilREMOVE@CAPSsympatico.caTHISTOO Word MVP site: http: / / www.word.mvps.org Word VBA Beginners Discussions Storing (1) Formatted (1) Variable xxFootnote" & i i = i + 1 Loop End Sub '_ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ - - Salut! _ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ Jean-Guy Marcil - Word MVP jmarcilREMOVE@CAPSsympatico.caTHISTOO Word MVP site: http: / / www.word.mvps.org Jean-Guy, I knew there were problems, it was
to delete only the page that my curser is in? Word VBA Discussions WdActiveEndAdjustedPageNumber (1) MVP (1) CAPSsympatico (1) JmarcilREMOVE (1) CaTHISTOO (1) ComputeStatistics (1) WdStatisticPages (1) ActiveDocument (1) Fuzzhead was telling us: Fuzzhead nous But beware of section breaks that may be deleted. . . - - Salut! _ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ Jean-Guy Marcil - Word MVP jmarcilREMOVE@CAPSsympatico.caTHISTOO Word MVP site: http: / / www.word.mvps.org This works good until I get to the last document you are handling and the type of content. - - Salut! _ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ Jean-Guy Marcil - Word MVP jmarcilREMOVE@CAPSsympatico.caTHISTOO Word MVP site: http: / / www.word.mvps.org This is part of
Edit, View, Insert, Format etc.) via vba code? All help is appreciated. Word VBA Discussions MVP (1) CAPSsympatico (1) JmarcilREMOVE (1) InsertInkAnnotations (1) CaTHISTOO (1) WordBasic (1) PC (1) OrgTry (1) rachitm@gmail.com was nous racontait que : What are you trying to do? - - Salut! _ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ Jean-Guy Marcil - Word MVP jmarcilREMOVE@CAPSsympatico.caTHISTOO Word MVP site: http: / / www.word.mvps.org Try the Commandbars object. (assuming you are in Word you use Word's built-in Ink Annotation button? - - Salut! _ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ Jean-Guy Marcil - Word MVP jmarcilREMOVE@CAPSsympatico.caTHISTOO Word MVP site: http: / / www.word.mvps.org the document is protected