Dir(MyPath,vbDirectory) Question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello all,

I am using the code below to get a file if it is in the folder and has an
extension of *.rcv. If I put another file extension it does not find it as
expected. However if I have a file extension of *.rcv_ it finds this too.
Is there a way to make it not find the underscore?

MyPath = "C:\data\*.rcv"
MyName = Dir(MyPath,vbDirectory)

sourcefile.rcv Expect to find
sourcefile.rcv_ Not Expect to find
 
Try leaving out the optional second argument for the Dir function:

MyName = Dir(MyPath)
 
Back
Top