Problem with reading contents of folder

J

Jay

Hi all

I'm trying to read the contents of a folder, find the files I want in that
folder, and then import them into tables within Access .. But I'm getting a
pretty major problem in the "reading the contents .. " part :

Set fs = Application.FileSearch
With fs
.LookIn = "C:\BB Stats\Season" & txtSeason & "\Week" & txtWeek
.FileName = "*.htm"

If .Execute(SortBy:=msoSortbyFileName,
SortOrder:=msoSortOrderAscending) > 0 Then

For i = 1 To .foundfiles.Count
Squads(i) = .foundfiles(i)

Next i

End With

The problem I'm getting is that everything just hangs at the If .Execute
statement .....

Now, the crazy thing about this is that I've done this one or two times
before in other things and it worked fine .. So, because I'm lazy, I just
lifted the code out of the previous things and pasted it in, changing just
the directory where I'm looking (the .Lookin) .. BUT

... going back to where I copied the above code from, now THAT doesn't work,
yet it worked fine in the past ..

Anybody any ideas?

Thx in advance

J
 
G

Guest

I'm no expert and this probably isn't the problem because it would have
thrown a compile time error but you don't close the If statement ie you close
the For loop and the With block but there is no 'End If'...

Hope that helps though!
 

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

Top