Alternative to FileSearch for Finding Directories
Andy,
Look at the second argument to the Dir function; you can use vbDirectory.
NickHK
"Andy" wrote in message
ps.com...
Thanks guys for your quick responses.
- I looked at DIR and maybe I'm not using it right, but it only seems
to find files rather than directories:
MsgBox(Dir(MyDir & "\08*")) doesn't find a directory named 08-000
or even 08
'MyDir is the path that contains the directory
- I tried your code Tom and it works nicely. However, I don't know the
full name of the directory I'm searching for, I only know the part
number which only makes up the first 12 digits of the directory, ie:
'01-000000-00 Left Flangy'
I did try a long shot to adapt the code using the 'Left' object, but to
no avail.
Andy
Tom Ogilvy wrote:
If I wanted to check for C:\Data1\Data3 I could do
Sub abc()
Dim fs As Object, dr As Object
Dim fldr As Object, fldr1 As Object
Set fs = CreateObject("Scripting.FileSystemObject")
Set dr = fs.Drives("C")
Set fldr = dr.RootFolder
On Error Resume Next
Set fldr1 = dr.RootFolder.SubFolders("Data1").SubFolders("Data 3")
On Error GoTo 0
If fldr1 Is Nothing Then
MsgBox "C:\Data1\Data3 does not exist"
Else
MsgBox fldr1.Path & " was found"
End If
End Sub
--
Regards,
Tom Ogilvy
" wrote:
I was extremely excited when I found FileSearch - it seemed like the
solution to an issue I hadn't manage to get round. Until I found out
the Filesearch isn't actually reliable and this was an issue on my
machine. So now I'm looking for an alternative.
I have a collection of directories which are named by a 12 digit part
number and a part name. I also have an excel sheet with the list of
part numbers in. I want to test to see if all the directories exist .
.. .without using filesearch.
Does anyone have any brilliant ideas?
Thanks
|