View Single Post
  #12   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Mr. Burton Mr. Burton is offline
external usenet poster
 
Posts: 14
Default Saving in 1 worksheet only

I had a reply to a different post "Disabling saving" by "Alan Moseley" that
solved this problem.

Try this. In the VBA editor add a new Class Module called Class1. Insert
the following code into it:-

Dim WithEvents MyExcel As Application
Dim booAllowSave As Boolean
Private Sub Class_Initialize()
Set MyExcel = Application
booAllowSave = False
End Sub
Private Sub Class_Terminate()
Set MyExcel = Nothing
End Sub
Private Sub MyExcel_WorkbookBeforeClose(ByVal Wb As Workbook, Cancel As
Boolean)
booAllowSave = False
End Sub
Private Sub MyExcel_WorkbookBeforeSave(ByVal Wb As Workbook, ByVal SaveAsUI
As Boolean, Cancel As Boolean)
If booAllowSave = False Then
Cancel = True
End If
End Sub

Now insert a new module and add the following code into it:-

Dim MyClass As Class1
Public Sub Auto_Open()

This works perfectly great work Alan!!!!

And thanks to every1 else who has helpout too.