Dir(MyPath,vbDirectory) Question

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
 
K

Ken Snell \(MVP\)

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

Similar Threads

Directory Inventory 1
Looking at properties of a file 1
Text Files import (about 1400 of them) 1
Dir 20
Insert OLE object 1
Help with Dir Function 3
Display sub-directory on a list box. 2
DIR() 1

Top