LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Crash on save

I have been pulling my hair out on this. Can anyone tell me why Excel
2K would crash after the BeforeSave event. My situation is this; I
have a workbook which has three sheet which all contain template style
information. I do not want the user to ever be able to overwrite
these template sheets. Normaly this is not a problem as I have hidden
(read replaced) the menu so they (the user) does not even get the
option. However when I make changes to the source and try to do a
save excel correctly does my BeforeSave code then saves the workbook
then dies. I have included my BeforeSave code below.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Dim objSheet As Worksheet

Application.DisplayAlerts = False
Application.ScreenUpdating = False

'Make sure we have our place holder sheet
'NOTE: This sheet is required since we can not save
' a workbook with no sheets
On Error Resume Next
Set objSheet = ThisWorkbook.Sheets("Sheet1")
On Error GoTo 0
If objSheet Is Nothing Then ThisWorkbook.Sheets.Add

'Delete all sheets other than place holder sheet
'We save without any of the 'Special' sheets so that
'all that is being saved is the source code for this
'workbook and not the template sheets. When the
'workbook is reloaded the special sheets will be added
'back in (See WorkBook.Open)
For Each objSheet In ThisWorkbook.Sheets
If objSheet.Name < "Sheet1" Then
g_blnIgnore = True
objSheet.Delete
g_blnIgnore = False
End If
Next

Application.ScreenUpdating = True
Application.DisplayAlerts = True

End Sub

Any thoughs
Thanks
Steve
 
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
VB Crash - Little Bit Of Fun RajenRajput1 Excel Discussion (Misc queries) 4 May 21st 07 02:35 PM
Crash martin Excel Discussion (Misc queries) 2 July 13th 05 09:36 PM
Path\File name length problem Excel Crash on save as Datasort Excel Discussion (Misc queries) 0 April 8th 05 05:19 PM
Crash on every 2nd run Christof[_4_] Excel Programming 1 September 29th 03 08:50 PM
Crash on every 2nd run Christof[_4_] Excel Programming 0 September 29th 03 07:57 AM


All times are GMT +1. The time now is 02:43 AM.

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

About Us

"It's about Microsoft Excel"