PDA

View Full Version : Change Read-Only Status (Excel '97)



phendrena
06-22-2009, 01:00 AM
Good morning,

Is it possible to change the Read Only status of a workbook once it has been opened via VBA?

Thanks,

shamsam1
06-22-2009, 03:29 AM
Function IsReadOnly(sWorkBook As String) As Boolean
Dim sFileFullName As String
sFileFullName = Workbooks(sWorkBook).FullName
If vbReadOnly Then
IsReadOnly = True
Else: IsReadOnly = False
End If
End Function

Sub test()
'change activeworkbook.name to any file you want to test
If IsReadOnly(ActiveWorkbook.Name) Then MsgBox "This workbook is read only"
End Sub

phendrena
06-22-2009, 03:39 AM
Thanks for the reply.
Thats not actually what i'm trying to do though.

I need to change the status of the workbook from or to Read-Only.