G
GPO
Access 2000
I am a sometime VBA dabbler trying to help a complete non-
programmer over the phone with a problem that does not
make sense to me (I can see we're off to a great start).
The following snippet is supposed to take a path and file:
(eg PathAndSelectedFile = "C:\Data\XXXXXXXa.txt")
and yeild a filename:
(eg FileToLoad = "XXXXXXXa.txt").
FileToLoad = _
Dir(Left(PathAndSelectedFile, _
Len(PathAndSelectedFile) - 5) & "?.txt", _
vbNormal)
It ALWAYS works properly on my pcs (Win 98, Win 2000, Win
XP), but my friend is adamant that it is yeilding the full
path and file (eg "C:\Data\XXXXXXXa.txt"), which is not
what we want.
Because I can't replicate it, I'm becoming a little
skeptical, but I would be grateful if someone could
confirm that this is a normal behaviour of Dir() and what
we can do to guarantee that we will only get the file and
not the path.
(Incidentally the "?.txt" is a wild card to find any file
named the same as the file in the PathAndSelectedFile
variable except for the fifth last char)
Regards
GPO
I am a sometime VBA dabbler trying to help a complete non-
programmer over the phone with a problem that does not
make sense to me (I can see we're off to a great start).
The following snippet is supposed to take a path and file:
(eg PathAndSelectedFile = "C:\Data\XXXXXXXa.txt")
and yeild a filename:
(eg FileToLoad = "XXXXXXXa.txt").
FileToLoad = _
Dir(Left(PathAndSelectedFile, _
Len(PathAndSelectedFile) - 5) & "?.txt", _
vbNormal)
It ALWAYS works properly on my pcs (Win 98, Win 2000, Win
XP), but my friend is adamant that it is yeilding the full
path and file (eg "C:\Data\XXXXXXXa.txt"), which is not
what we want.
Because I can't replicate it, I'm becoming a little
skeptical, but I would be grateful if someone could
confirm that this is a normal behaviour of Dir() and what
we can do to guarantee that we will only get the file and
not the path.
(Incidentally the "?.txt" is a wild card to find any file
named the same as the file in the PathAndSelectedFile
variable except for the fifth last char)
Regards
GPO