This is the code to set or un-set the Read Only bit.
Sub SetReadOnlyBit(filespec)
Dim fs, f, r
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(fs.GetFileName(filespec))
'Note: "1" is the Read Only code!
If f.Attributes And 1 Then
r = MsgBox("The Read Only bit is set, do you want to clear it?", vbYesNo, "Set/Clear Read Only Bit")
If r = vbYes Then
f.Attributes = f.Attributes - 1
MsgBox "Read Only bit is cleared."
Else
MsgBox "Read Only bit remains set."
End If
Else
r = MsgBox("The Read Only bit is not set. Do you want to set it?", vbYesNo, "Set/Clear Read Only Bit")
If r = vbYes Then
f.Attributes = f.Attributes + 1
MsgBox "Read Only bit is set."
Else
MsgBox "Read Only bit remains clear."
End If
End If
End Sub
Hope this helps you. JSW
Re: Properties "a question"
Hi Joe
Thanks for the help, one question, where do i put
the code in Workbook_BeforeClose?
Jim
Re: Properties "a question"
In the module named ThisBook.
I have another suggestion. When you do a saveas, click options, and set a password for "Write". Because you could change the properties using Explorer and then open it as a normal file, even though the code had run the last time, setting it to read only.
Juan Pablo G. Hi Joe Thanks for the help, one question, where do i put