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
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
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: )
 
Upvote 0
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
 
Upvote 0
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.
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,479
Members
448,967
Latest member
visheshkotha

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top