ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA - Protecting from Save (https://www.excelbanter.com/excel-programming/281186-vba-protecting-save.html)

HRobertson

VBA - Protecting from Save
 
Is there a code to write that will allow users of the file
to only SAVE AS, and not SAVE? Please help, I'm having
trouble preventing people from using SAVE on template
forms I built, and therefore their info. is there every
time I open the files. Thank you very much!

Trevor Shuttleworth

VBA - Protecting from Save
 
In the ThisWorkbook Class Module:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)

If SaveAsUI = False Then Cancel = True

End Sub

Regards

Trevor


"HRobertson" wrote in message
...
Is there a code to write that will allow users of the file
to only SAVE AS, and not SAVE? Please help, I'm having
trouble preventing people from using SAVE on template
forms I built, and therefore their info. is there every
time I open the files. Thank you very much!




Tom Ogilvy

VBA - Protecting from Save
 
Put in a workbook_Open event that prompts for a file name and saves the
file.

Private Sub Workbook_Open()
Dim fname as String
if ThisWorkbook.Name = "TemplateName.xls" then
fname = application.GetSaveAsFilename()
if fname = "false" then fname = "TemplateName" &
format(date,"yyyymmdd_hhmm") _
& ".xls"
Thisworkbook.SaveAs fname
End if
End Sub

--
Regards,
Tom Ogilvy


"HRobertson" wrote in message
...
Is there a code to write that will allow users of the file
to only SAVE AS, and not SAVE? Please help, I'm having
trouble preventing people from using SAVE on template
forms I built, and therefore their info. is there every
time I open the files. Thank you very much!




Tom Ogilvy

VBA - Protecting from Save
 
Another approach would be mark the template as Read-Only using Windows
explorer, right clicking on the file and selecting options.

--
Regards,
Tom Ogilvy

"HRobertson" wrote in message
...
Is there a code to write that will allow users of the file
to only SAVE AS, and not SAVE? Please help, I'm having
trouble preventing people from using SAVE on template
forms I built, and therefore their info. is there every
time I open the files. Thank you very much!





All times are GMT +1. The time now is 07:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com