Looking through server files

  • Thread starter Thread starter Toby
  • Start date Start date
T

Toby

I have many files on a web server that i need to import
into an access table. I know how to import files
programmatically, but how do I loop through a list of
Paths to get to these files?
 
Hi:

Try using the FileSystemObject.

In your Access VBA project make a reference to "Microsoft Scripting Runtime"

Now try this code

Dim fs as New Scripting.FileSystemObject
Dim fo as Scripting.Folder
Dim f as Scripting.File

Set fo = fs.GetFolder(strFolderPath) 'strFolder is path of folder to scan
For each f in fo.Files
if UCase(Right(f.name,4)) = ".DOC"
'do what is need to import file (Import f.FullName)
end if
Next

Regards,

Naresh Nichani
Microsoft Access MVP
 
Back
Top