Do Not Overwrite File Code

nathanpeattie

New Member
Joined
Dec 17, 2005
Messages
43
I have a master file that I use and I have a button that saves this master file as something else when the user is done.

My problem is if the user clicks the save button at the top it overwrites my master file to what they have done I don't want this to happen how can I fix.

Thanks
 

Some videos you may like

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Barrie Davidson

MrExcel MVP
Joined
Feb 10, 2002
Messages
2,330
Have you thought about saving the master with a password? The users can open the master but it's read only so they cannot over-write the file but they can save it under a different name.

Best regards,

PS - congrats on getting a great QB (I'm assuming you're a TiCat fan :cool: )
 

nathanpeattie

New Member
Joined
Dec 17, 2005
Messages
43
How about just as a read only and no password my users want no passwords.

Will setting it as just a readonly still allow me to save it as something else?

Thanks
 

Barrie Davidson

MrExcel MVP
Joined
Feb 10, 2002
Messages
2,330
nathanpeattie said:
How about just as a read only and no password my users want no passwords.
The password would only be required if you want to open it with read/write capabilities.

nathanpeattie said:
Will setting it as just a readonly still allow me to save it as something else?
Yes.
 

Joe Was

MrExcel MVP
Joined
Feb 19, 2002
Messages
7,539
The code below traps the File Save/SaveAs icon and menu items, only allowing the Workbook to be saved by a UserDefined Button that saves the Workbook!



Public myFlg As Boolean

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, cancel As Boolean)
'ThisWorkbook module code!

If myFlg = True Then
GoTo myEnd
Else
cancel = True
End If

myEnd:
End Sub

Sub myButtonSave()
'ThisWorkbook module code!
Dim fName$

myFlg = True
fName = "C:\cp\Test33.xls"

ActiveWorkbook.SaveAs Filename:=fName
myFlg = False
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,119,002
Messages
5,575,488
Members
412,669
Latest member
nickyon1
Top