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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top