This sets the active Workbook to Read-Only or Not.
Sub myReadOnly()
'Sheet module code, like: Sheet1.
Dim fs, f, r
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(fs.GetFileName(ActiveWorkbook.FullName))
'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
This is the key to setting it read only:
Dim fs, f
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(fs.GetFileName(ActiveWorkbook.FullName))
f.Attributes = f.Attributes + 1