View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Jim Cone Jim Cone is offline
external usenet poster
 
Posts: 3,290
Default How to test if a repertory is valid

Alex,
Just adding an "on error resume next" makes it work.
Also, "Path" is an Excel property and should not be used as a variable name.
This works ...
'---------------------------------
Sub TestForPath()
Dim strPath As String
Dim lngPathLength As Long

strPath = "VV:\temp\"
On Error Resume Next
lngPathLength = Len(Dir$(strPath, vbDirectory))
On Error GoTo 0
If lngPathLength = 0 Then
MsgBox (strPath & vbCr & " Not valid ")
End If
End Sub
'--------------------------------------------------

Regards,
Jim Cone
San Francisco, USA



"Alex St-Pierre" wrote in message
...
Hello,
I want a function that test if any path is a valid path. This function makes
an error when you are typing a path like the one writen below. Does anyone
know how to stop this error?
path = "VV:\temp\"
If Len(Dir$(path, vbDirectory)) = 0 Then
msgbox("the path is not valid")
exit sub
endif
Thanks,
Alex St-Pierre