I know that you can test if a file exists but can you test if a folder
exists. if so what is the VBA code for it?
Any help appreciated especially examples of code
Thanks
Jonathan West - 11 Jan 2006 20:33 GMT
>I know that you can test if a file exists but can you test if a folder
> exists. if so what is the VBA code for it?
>
> Any help appreciated especially examples of code
>
> Thanks
Take a look here
http://vbnet.mvps.org/code/fileapi/folderexists.htm

Signature
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
Karl E. Peterson - 11 Jan 2006 21:04 GMT
> I know that you can test if a file exists but can you test if a folder
> exists. if so what is the VBA code for it?
Lots of folks will advise something like this is the simplest way:
Private Function FolderExists(PathName As String) As Boolean
If Len(PathName) > 0 Then
On Error Resume Next
FolderExists = ((GetAttr(PathName) And vbDirectory) > 0)
Err.Clear
End If
End Function

Signature
Be the 10,000th Signer!
http://classicvb.org
Doug Robbins - Word MVP - 11 Jan 2006 21:50 GMT
You can make use of the fact that you will get a Run time error 76 if the
path does not exist when you use ChDir("path")

Signature
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
>I know that you can test if a file exists but can you test if a folder
> exists. if so what is the VBA code for it?
>
> Any help appreciated especially examples of code
>
> Thanks