I wanted to make sure everyone noted that I found a bug in my previously <A target="_blank" HREF=http://www.wopr.com/cgi-bin/w3t/showthreaded.pl?Cat=&Board=vb&Number=38271&page=0& view=collapsed&sb=5&o=0&vc=1#Post38271>posted code</A> <img src=/S/shocked.gif border=0 alt=shocked width=15 height=15>

So, I'm reposting this from the above thread and adding an additional note.

If you passed into the function a filename of the empty string, the function returned true (due to the Dir command interpreting the "" as nothing which means get the next file (apparently) -- in this case the first file in the current folder). Not good. The FolderExists function had the same problem.

Here are the functions updated. Also, you might be interested in the API call SHFileExists to accomplish the testing of file existence. I don't recall reading any mention of that method.

Public Function fFolderExists(strFullName As Variant) As Boolean
If Len(strFullName) <> 0 Then
fFolderExists = Len(Dir(strFullName, vbDirectory))
End If
End Function

Public Function fFileExists(strFullName As String) As Boolean
If Len(strFullName) <> 0 Then
fFileExists = Len(Dir(strFullName, vbNormal))
End If
End Function

Thanks to Al for inspiring me to take a closer look!