Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 169
Default How to test if a repertory is valid

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default How to test if a repertory is valid

"?B?QWxleCBTdC1QaWVycmU=?="
wrote in
:

Take a look at this webpage:
http://www.sloppycode.net/Reference/FSO/Ref-80.html
It is probably what you are looking for.

HTH,
CoRrRan

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,


  #3   Report Post  
Posted to microsoft.public.excel.programming
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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to do - B2 is only valid if B1 is zero declaire9 Excel Discussion (Misc queries) 1 April 13th 10 06:45 PM
Can you help test our Excel test? Jeff[_14_] Excel Discussion (Misc queries) 1 December 7th 09 05:11 PM
Calculate mean of test scores from rows of test answers RiotLoadTime Excel Discussion (Misc queries) 1 July 26th 06 05:14 PM
test..where are my messages..test HT New Users to Excel 0 January 23rd 05 06:23 PM
Not A Valid Add-In [email protected] Excel Programming 3 November 3rd 04 04:59 PM


All times are GMT +1. The time now is 10:44 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"