E
Eric G
Snippet of code from my routine to check file permissions is below.
Represents my crude attempt to check whether or not I have permission to
access a file.
For Each oFile In Dir.Files
fileIsOkay = False
On Error GoTo Bad_Permission
Set ts = oFile.OpenAsTextStream '<<== Blows up here on second bad
file
ts.Close
Set ts = Nothing
On Error GoTo 0 '<<== This should reset the error, right?
fileIsOkay = True ' If we got here, I have access to the file
Bad_Permission:
On Error GoTo 0
tName = oFile.Name
If (Not fileIsOkay) Then
tName = tName & ": PERMISSION PROBLEM"
Else
tName = tName & ": OKAY"
End If
Debug.Print tName
Next oFile
I loop through all files in the given (test) folder. I know there are a
couple of files that I don't have permissions to view. When the first one is
checked using the code above, it triggers the On Error and gives the
appropriate message. When I hit the second "bad" file, I get "Run-time error
'70': Permission denied" instead. The On Error code no longer works. What
am I doing wrong?
Thanks in advance,
Eric
Represents my crude attempt to check whether or not I have permission to
access a file.
For Each oFile In Dir.Files
fileIsOkay = False
On Error GoTo Bad_Permission
Set ts = oFile.OpenAsTextStream '<<== Blows up here on second bad
file
ts.Close
Set ts = Nothing
On Error GoTo 0 '<<== This should reset the error, right?
fileIsOkay = True ' If we got here, I have access to the file
Bad_Permission:
On Error GoTo 0
tName = oFile.Name
If (Not fileIsOkay) Then
tName = tName & ": PERMISSION PROBLEM"
Else
tName = tName & ": OKAY"
End If
Debug.Print tName
Next oFile
I loop through all files in the given (test) folder. I know there are a
couple of files that I don't have permissions to view. When the first one is
checked using the code above, it triggers the On Error and gives the
appropriate message. When I hit the second "bad" file, I get "Run-time error
'70': Permission denied" instead. The On Error code no longer works. What
am I doing wrong?
Thanks in advance,
Eric