#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 14
Default Disabling saving

Hi, I need to get rid of the save option. I only want the sheet able save
when the document is closed and it askes if you want to save. I do not want
the document to be saved any other time.

Here is my document (Office 2007 Only).

http://www.savefile.com/files/1848919

It has been made to book out computer and laptop suites.
Trouble is, some people delete others booked sessions and put their own in.

So I have a macro that locks a cell after data is entered into the cell. As
the sheet is protected anybody trying to delete it afterwards cannot.

Trouble was they would have to enable macros to use the macro. That's like
asking a thief to leave his address when he robs a bank.
So the important sheets are veryhidden & I have another macro that unhides
them when you enable macros. Therefore they cannot access the other sheets
until macros are enabled.

My last problem is that if they enable macros then save when they on the
unhidden sheets & save, then quit without saving they document stays on the
veryhidden sheets. Which is not good as the macros are not enabled.

Gord has tried but been unable to assist and could some other kind soul have
a look.Thanks
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 75
Default Disabling saving

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()
Set MyClass = New Class1
End Sub
Public Sub Auto_Close()
Set MyClass = Nothing
End Sub

--
Alan Moseley IT Consultancy
http://www.amitc.co.uk


"Mr. Burton" wrote:

Hi, I need to get rid of the save option. I only want the sheet able save
when the document is closed and it askes if you want to save. I do not want
the document to be saved any other time.

Here is my document (Office 2007 Only).

http://www.savefile.com/files/1848919

It has been made to book out computer and laptop suites.
Trouble is, some people delete others booked sessions and put their own in.

So I have a macro that locks a cell after data is entered into the cell. As
the sheet is protected anybody trying to delete it afterwards cannot.

Trouble was they would have to enable macros to use the macro. That's like
asking a thief to leave his address when he robs a bank.
So the important sheets are veryhidden & I have another macro that unhides
them when you enable macros. Therefore they cannot access the other sheets
until macros are enabled.

My last problem is that if they enable macros then save when they on the
unhidden sheets & save, then quit without saving they document stays on the
veryhidden sheets. Which is not good as the macros are not enabled.

Gord has tried but been unable to assist and could some other kind soul have
a look.Thanks

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 14
Default Disabling saving

Hi, I've entered what you wrote and I get a compile error on 2 lines:

Private Sub MyExcel_WorkbookBeforeClose(ByVal Wb As Workbook, Cancel As
Boolean)

&

Private Sub MyExcel_WorkbookBeforeSave(ByVal Wb As Workbook, ByVal SaveAsUI
As Boolean, Cancel As Boolean)

Thanks for helping

"Alan Moseley" wrote:

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()
Set MyClass = New Class1
End Sub
Public Sub Auto_Close()
Set MyClass = Nothing
End Sub

--
Alan Moseley IT Consultancy
http://www.amitc.co.uk


"Mr. Burton" wrote:

Hi, I need to get rid of the save option. I only want the sheet able save
when the document is closed and it askes if you want to save. I do not want
the document to be saved any other time.

Here is my document (Office 2007 Only).

http://www.savefile.com/files/1848919

It has been made to book out computer and laptop suites.
Trouble is, some people delete others booked sessions and put their own in.

So I have a macro that locks a cell after data is entered into the cell. As
the sheet is protected anybody trying to delete it afterwards cannot.

Trouble was they would have to enable macros to use the macro. That's like
asking a thief to leave his address when he robs a bank.
So the important sheets are veryhidden & I have another macro that unhides
them when you enable macros. Therefore they cannot access the other sheets
until macros are enabled.

My last problem is that if they enable macros then save when they on the
unhidden sheets & save, then quit without saving they document stays on the
veryhidden sheets. Which is not good as the macros are not enabled.

Gord has tried but been unable to assist and could some other kind soul have
a look.Thanks

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 75
Default Disabling saving

Sorry, I am using Outlook 2003 so we may not have the declaration correct.
Remove everything from within the class module except for the following:-

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

Now go to the top of the class code screen and select MyExcel from the
drop-down list of objects, and then WorkbookBeforeClose from the list of
available events. Now include this code in the newly created sub:-

booAllowSave = False

Now choose MyExcel again from the object list and WorkbookBeforeSave from
the list of events. Include the following code within the newly created sub:-

If booAllowSave = False Then
Cancel = True
End If

Recompile the code and save the workbook. Close the workbook and see if it
works. In the mean-time I will see if I can find out the correct declaration
just in case you can't get the above to work.

--
Alan Moseley IT Consultancy
http://www.amitc.co.uk


"Mr. Burton" wrote:

Hi, I've entered what you wrote and I get a compile error on 2 lines:

Private Sub MyExcel_WorkbookBeforeClose(ByVal Wb As Workbook, Cancel As
Boolean)

&

Private Sub MyExcel_WorkbookBeforeSave(ByVal Wb As Workbook, ByVal SaveAsUI
As Boolean, Cancel As Boolean)

Thanks for helping

"Alan Moseley" wrote:

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()
Set MyClass = New Class1
End Sub
Public Sub Auto_Close()
Set MyClass = Nothing
End Sub

--
Alan Moseley IT Consultancy
http://www.amitc.co.uk


"Mr. Burton" wrote:

Hi, I need to get rid of the save option. I only want the sheet able save
when the document is closed and it askes if you want to save. I do not want
the document to be saved any other time.

Here is my document (Office 2007 Only).

http://www.savefile.com/files/1848919

It has been made to book out computer and laptop suites.
Trouble is, some people delete others booked sessions and put their own in.

So I have a macro that locks a cell after data is entered into the cell. As
the sheet is protected anybody trying to delete it afterwards cannot.

Trouble was they would have to enable macros to use the macro. That's like
asking a thief to leave his address when he robs a bank.
So the important sheets are veryhidden & I have another macro that unhides
them when you enable macros. Therefore they cannot access the other sheets
until macros are enabled.

My last problem is that if they enable macros then save when they on the
unhidden sheets & save, then quit without saving they document stays on the
veryhidden sheets. Which is not good as the macros are not enabled.

Gord has tried but been unable to assist and could some other kind soul have
a look.Thanks

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 14
Default Disabling saving

That worked perfectly

Great thanks alot. A big help.

"Alan Moseley" wrote:

Sorry, I am using Outlook 2003 so we may not have the declaration correct.
Remove everything from within the class module except for the following:-

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

Now go to the top of the class code screen and select MyExcel from the
drop-down list of objects, and then WorkbookBeforeClose from the list of
available events. Now include this code in the newly created sub:-

booAllowSave = False

Now choose MyExcel again from the object list and WorkbookBeforeSave from
the list of events. Include the following code within the newly created sub:-

If booAllowSave = False Then
Cancel = True
End If

Recompile the code and save the workbook. Close the workbook and see if it
works. In the mean-time I will see if I can find out the correct declaration
just in case you can't get the above to work.

--
Alan Moseley IT Consultancy
http://www.amitc.co.uk


"Mr. Burton" wrote:

Hi, I've entered what you wrote and I get a compile error on 2 lines:

Private Sub MyExcel_WorkbookBeforeClose(ByVal Wb As Workbook, Cancel As
Boolean)

&

Private Sub MyExcel_WorkbookBeforeSave(ByVal Wb As Workbook, ByVal SaveAsUI
As Boolean, Cancel As Boolean)

Thanks for helping

"Alan Moseley" wrote:

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()
Set MyClass = New Class1
End Sub
Public Sub Auto_Close()
Set MyClass = Nothing
End Sub

--
Alan Moseley IT Consultancy
http://www.amitc.co.uk


"Mr. Burton" wrote:

Hi, I need to get rid of the save option. I only want the sheet able save
when the document is closed and it askes if you want to save. I do not want
the document to be saved any other time.

Here is my document (Office 2007 Only).

http://www.savefile.com/files/1848919

It has been made to book out computer and laptop suites.
Trouble is, some people delete others booked sessions and put their own in.

So I have a macro that locks a cell after data is entered into the cell. As
the sheet is protected anybody trying to delete it afterwards cannot.

Trouble was they would have to enable macros to use the macro. That's like
asking a thief to leave his address when he robs a bank.
So the important sheets are veryhidden & I have another macro that unhides
them when you enable macros. Therefore they cannot access the other sheets
until macros are enabled.

My last problem is that if they enable macros then save when they on the
unhidden sheets & save, then quit without saving they document stays on the
veryhidden sheets. Which is not good as the macros are not enabled.

Gord has tried but been unable to assist and could some other kind soul have
a look.Thanks

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
Disabling Cut and Copy Varne Excel Discussion (Misc queries) 13 August 21st 08 03:12 PM
Disabling formula Mel D Excel Discussion (Misc queries) 2 May 25th 08 10:54 PM
Disabling the cut function? Tim G. Excel Discussion (Misc queries) 3 September 27th 06 05:01 PM
Disabling updatelinks Dave Excel Discussion (Misc queries) 0 April 27th 06 12:05 PM
disabling CUT function Keef Excel Discussion (Misc queries) 2 January 23rd 05 12:17 AM


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

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"