Saving it as read only?

A

andycharger

Can someone help me?

Im trying to save a spreadsheet as read only.
However, When I look through the options on the code in VBA, I canno
see an option for read only? Only Read Only Recommended.

I tried setting the Activeworkbook.Writepassword = "password"
but this just prevents me saving the spreadsheet altogether as it say
it cannot access read only document "Quotes 2004"


Here is my code

Activeworkbook.Writepassword = "password"

chdir "C:\"

ActiveWorkBook.Saveas Filename :="Y:\working files\quotes2004.xls"
FileFormat:=xlNormal, Password:="", readonlyrecommended="false"


Any ideas
 
K

kkknie

Not sure the exact reason for wanting it to be read only, but here'
some suggestions.

- Protect the workbook with a password. Then the user will not be abl
to make any changes (so saving it would not matter).

- Save the workbook to a directory that the users only hav
Read/Execute privelage. (my preference)
 
A

andycharger

In my example, it is setting the file to have a password if you look a
the VBA but that is not sufficient.

I have found out that I need to do the following:

SetAttr filename, vbReadOnly

but i need to delete the original file first as it wont let m
overwite

Anyone know how I delete the original file without opening it?

Any hlep would be appreciated
 
T

Tom Ogilvy

I don't know if you want a password or not, but having a password doesn't
have much to do with readonly.

for readonly , save the workbook as normal, close it, then use the setattr
to mark it as read only. See VBA help for arguments to setattr.
 
Top