Is filepath valid?
I was going to answer as Mike did, but in testing I saw something I'd never
noticed before - if you are looking at a server or shared drive on a
network, referring to one that does not exist with DIR yields an error, not
just an empty string, as Dir usually does. At least I think that's what I'm
seeing. So here's my function:
Function valid_path_and_file(path_and_file As String) As Boolean
Dim tester As String
On Error Resume Next
tester = Dir(path_and_file, vbDirectory)
If Err.Description = "" Then 'If Server5 and SHARE exist
If tester < "" Then
valid_path_and_file = True
End If
End If
On Error GoTo 0
End Function
I called it with this. Again if Server5 or SHARE do not exist, Dir errored
in my test, but the function above did not:
Sub test()
Debug.Print valid_path_and_file("\\Server5\SHARE\GENERAL\test. doc")
End Sub
hth,
Doug
"Rookie_User" wrote in message
...
I have a column that contains a file path with the file at the end - all
contained in the cell. There are about 150 rows. I would like to put
something in column be that says - yes the path and file are truly there
or
No it is invalid. I have searched multiple places and have not found
anything pointing to how to do this?
|