View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
JMay JMay is offline
external usenet poster
 
Posts: 422
Default Don't understand results of UDF

JE - Thanks for clearing up my confusion. Obviously,
the Code searches at the Folder level ONLY;
It was the reference in the code *.* that confused me.
This should never happen again. LOL
Tks,
Jim

"JE McGimpsey" wrote in message
:

Because

C:\Documents and Settings\XlsFileSavedAsText.txt\*.*

definitely DOESN'T exist.

Your UDF is looking for a Path, not the entire filename.

If you remove the "\XlsFileSavedAsText.txt" from B3, then PathExists
will return TRUE.



In article , "JMay"
wrote:

In cell B4 I have (as text):

C:\Documents and Settings\XlsFileSavedAsText.txt

In Cell C2 I have:

=PathExists(B4)

In my Module1 I have:

Private Function PathExists(PathName As String) As Boolean
' Returns True If PathExists
On Error GoTo NoPath
x = Dir(PathName & "\*.*")
If x = "" Then GoTo NoPath
PathExists = True
Exit Function
NoPath:
PathExists = False
End Function

Why is my Cell C2 showing False
when I definitely
C:\Documents and Settings\XlsFileSavedAsText.txt Exists?

TIA,

Jim