Thursday, August 30, 2012 3:13 PM
I have a problem with a specific Excel file that crash every time you try to close it. Others files don't crash.
this is the error code, i tried to find other similar cases but i haven't find anything.
Excel Version is 2007
Can anybody help me?
Thursday, August 30, 2012 3:22 PM
Does it have macros in it?
This will be really hard to diagnose without actually seeing the file. Could you sanitize it of any proprietary information and send it to me at firstname.lastname@example.org?
Thursday, August 30, 2012 4:00 PM
Yes, there are several macros.
The error and the consequent closing of the file is very troublesome because a lot of people have to use it and if they lose the work on other files it's a problem for me!
(sorry for my english! :-))
Thursday, August 30, 2012 4:18 PMI got the file in email. I'll have to wait to load it on a computer that I have WinRAR installed on. I'll get back to you.
Thursday, August 30, 2012 6:11 PM
It sounds like an XLSM file. I've witnessed problems on close as well....not the same module as yours however.
To remedy: Start Excel, select your file, then from the dropdown, do an Open and Repair, save it....close Excel, reopen.
Friday, August 31, 2012 7:19 AM
thanks for your answer; i tried to do an Open and Repair but the file still crash on close.
Friday, August 31, 2012 7:36 AM
Following your questions about macros i tried to remove one macro that save a log file before close file.
Now it seems ok...
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Not ThisWorkbook.ReadOnly Then
KillCurrentUserLog ' delete the last user information
' or add the last user information to the log history
' bIsClosing = True
'Turn off events to prevent unwanted loops
Application.EnableEvents = False
'Evaluate if workbook is saved and emulate default propmts
If Not .Saved Then
Select Case MsgBox("Do you want to save the changes you made to '" & .Name & "'?", _
vbYesNoCancel + vbExclamation)
Case Is = vbYes
'Call customized save routine
Case Is = vbNo
'Do not save
Case Is = vbCancel
'Set up procedure to cancel close
Cancel = True
'If Cancel was clicked, turn events back on and cancel close,
'otherwise close the workbook without saving further changes
If Not Cancel = True Then
.Saved = True
Application.EnableEvents = True
Application.EnableEvents = True
Do you know why this macro crash file?
- Edited by pinaz81 Friday, August 31, 2012 7:37 AM
Friday, August 31, 2012 12:33 PM
Everything below " ' Turn off events to prevent unwanted loops" seems like it should be pretty innocuous. I think the real question is what's in your KillCurrentUserLog, LogThisUserAction, and CustomSave subroutines.
Try re-including this event code in your workbook, then commenting out these three routines, one at a time (with the other two un-commented-out), and checking for the Excel crash. That will help narrow down where the problem is.
Friday, August 31, 2012 1:20 PMModerator
I believe and I could be wrong but my best guess is that the code is crashing while calling CustomSave. What does that procedure do?
Also try this. Wherever you are actually saving the workbook before quitting Excel, add doevents after that line for example
' '~~> Rest of the code ' ActiveWorkbook.Save DoEvents ' '~~> Rest of the code '
Sid (A good exercise for the Heart is to bend down and help another up) Please do not email me your questions. I do not answer questions by email unless I get paid for it :) If you want, create a thread in VB.Net/Excel forum and email me the link and I will help you if I can.
Friday, August 31, 2012 1:27 PM
Pinaz - I can't believe you didn't mention in your first post there was code in the Before_Close event handler.
On top of that, you didn't mention which of the 3 user options that could be selected caused the crash.
- Marked As Answer by Leo_GaoModerator Monday, September 10, 2012 7:25 AM
Friday, August 31, 2012 4:45 PM
I thought that with error code someone could understand what was the problem and also I'm not an expert user so I didn't thought that some macro could crash this file and not another files with the same code inside.
Thanks all for the support, now I will try to apply your suggestion... Only I'm not very expert so I have to try and try...
Tuesday, September 04, 2012 11:55 AM
Error codes are rarely enough on their own to diagnose problems with code someone else has written. The only reason they're useful to Microsoft, for example, when a Microsoft product crashes is that it's a Microsoft product that's crashed. An Adobe Reader error code would probably not be very informative to a Microsoft engineer.
(To note: I don't think anything in the image you originally posted is actually an error code -- all of the codes you included in your screenshot just look like internal identifiers for Excel.)
If your CustomSave macro doesn't have anything proprietary in it, just post the whole thing in this thread so people can peruse it. Otherwise, no one has any idea of what you're trying to do.