VBA - Protecting from Save

  • Thread starter Thread starter HRobertson
  • Start date Start date
H

HRobertson

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!
 
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
 
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
 
Another approach would be mark the template as Read-Only using Windows
explorer, right clicking on the file and selecting options.
 
Back
Top