View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Error than Aborted Excel

Excel shouldn't have crashed with this type of error.

And I bet if you do a couple of tests, it won't.

Try building a new workbook with just enough test data to run your code. Copy
over just enough code (with the error) and run it.

I bet excel warned you and didn't crash.

Now try it again with the old workbook (re-introduce the error first). Does it
still crash?

If it does crash, then there's something wrong with your workbook or excel. If
the smaller test workbook didn't crash, it leads me to believe that something is
wrong with your old workbook.

Maybe cleaning the code with Rob Bovey's code cleaner would help:
You can find it he
http://www.appspro.com/
or directly
http://www.appspro.com/Utilities/CodeCleaner.htm

Or maybe there's a corrupted worksheet (or more) that needs to be rebuilt????

But excel shouldn't crash on a bug like this.


Neal Zimm wrote:

Hi All,

sHold = sHold & sColData & Space(MaxLenAy(iSortOrder) - Len(sColData))
Debug.Print sHold
sHold = ""

The lines above are part of a proc that prints evenly 'lined-up' columns.
Due to a bug, the Space math worked out to -2. The bug is now fixed,

BUT, Excel ENDED with the "Excel has a problem and has to close..."
display and my files were recovered. (No On Error .... code was in
place at the time.)

1. There was no run-time error. Why ?

When I extracted parts of the code to debug it, in testing the fix
I got a run- time error with a negative number.

2. Without putting all the code here, can you tell me what might be
the difference between getting a run-time error or not ?

3. Do you know of any other "common" uses of VBA that will abort Excel
without a run-time error so I can take special care with them?

Thanks,
Neal
--
Neal Z


--

Dave Peterson