Silverryggen
New Member
- Joined
- Jan 25, 2010
- Messages
- 5
Hi,
I am trying to create a function in VBA that checks if the target file is write protected before opening it. I have tried the code below without any luck
Filename is a variable passed in from the main sub.
Hopefully someone knows the answer to this problem
Function Protected (Filename) As Boolean
Dim test As Boolean
On Error Resume Next
Application.DisplayAlerts = False
If Workbooks(Filename).ReadOnly Then
Protected = True
Else
Protected = False
End If
Application.DisplayAlerts = True
End Function
I am trying to create a function in VBA that checks if the target file is write protected before opening it. I have tried the code below without any luck
Filename is a variable passed in from the main sub.
Hopefully someone knows the answer to this problem
Function Protected (Filename) As Boolean
Dim test As Boolean
On Error Resume Next
Application.DisplayAlerts = False
If Workbooks(Filename).ReadOnly Then
Protected = True
Else
Protected = False
End If
Application.DisplayAlerts = True
End Function