Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Excel 2002 aborts randomly when closing/saving workbook

Help!....I am at my wit's end. I have an Excel 2002 workbook, appr 1 MG,
containing 28 worksheets, 6 userforms, and a fair amount of VBA code.

When closing/saving the workbook, I am (randomly) experiencing the
"Microsoft Excel has encountered a problem and needs to close. We are sorry
for the inconvenience.." It seems to happen more frequently if I have
entered a row or two to several of the worksheets and then close (vs. adding
a row to 1 worksheet, then saving or closing).
Here is the code. Note: when run in debug mode, processing seems to
"hang" on the Me.Save line.

Thanks,
Barb Ryan

Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error GoTo err_Workbook_BeforeClose

Let varAnswer = Null
Application.EnableEvents = False
If Not Me.Saved Then
Dim strMsg As String
strMsg = "Do you want to save the changes you made to "
strMsg = strMsg & Me.Name & "?"
varAnswer = MsgBox(strMsg, vbQuestion + vbYesNoCancel)
Select Case varAnswer
Case vbYes
Me.Save
Case vbNo
Me.Saved = True
Case vbCancel
Cancel = True
Let varAnswer = Null
Exit Sub
End Select
End If
Application.CommandBars("AUR_Custom").Delete
Let varAnswer = Null
Application.EnableEvents = True
Application.ScreenUpdating = True

exit_Workbook_BeforeClose:
Exit Sub

err_Workbook_BeforeClose:
MsgBox Err.Number & ": " & Err.Description
Resume exit_Workbook_BeforeClose

End Sub

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Dim strBookmark As String

strBookmark = ActiveSheet.Name
If IsNull(varAnswer) Or IsEmpty(varAnswer) Then 'no need to redefine
if we are closing workbook
Application.ScreenUpdating = False
RedefineRangeNames
Application.ScreenUpdating = True
End If
Sheets(strBookmark).Select
Range("LastSaveDate").Value = Now()

End Sub



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems saving Workbook as webpage with interactivity (Excel 2002 tech1NJ Excel Worksheet Functions 0 October 5th 09 08:43 PM
Closing a workbook without saving from Word [email protected] Excel Programming 3 June 9th 05 09:43 PM
Closing Workbook without Saving Chris Gorham[_3_] Excel Programming 2 December 11th 03 12:17 AM
Saving in Excel 97 a workbook developed in Excel 2002 David WIlliamson Excel Programming 1 November 26th 03 12:35 PM
Closing a workbook without saving Darrin Henry Excel Programming 2 September 24th 03 02:31 PM


All times are GMT +1. The time now is 05:09 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"