Read-Only Files in VBA
I have a file which I would like to make read-only and be able to save it (read-only again) from a button press in a sheet which has limited access to it - ie you need a password to gain access to that sheet .... the limited access with password bit is all done. I have code (below) to save the file when not read only, but how can I make a file read-only, so that I can save it through vba software so that it remains read-only. Is it possible to do it in a way that is similar to protecting a sheet (ActiveSheet.Unprotect "test" & ActiveSheet.Protect "test")??
My (non-Read only code) is below ......
Dim progname As String
progname = Sheets("Data").Range("C30").Value
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:= _
progname, FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
Application.DisplayAlerts = True
I understand there is the SetAttr statement, but I want to do it from the name progfile, rather than list the whole program name in commas ie "C:\documents\test\......" as the name is quite long.
Any help would be greatly appreciated, Thanks.