Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
VB Crash - Little Bit Of Fun | Excel Discussion (Misc queries) | |||
Crash | Excel Discussion (Misc queries) | |||
Path\File name length problem Excel Crash on save as | Excel Discussion (Misc queries) | |||
Crash on every 2nd run | Excel Programming | |||
Crash on every 2nd run | Excel Programming |