Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I do this? 2

Status
Not open for further replies.

PerryG

Programmer
Joined
Aug 15, 2000
Messages
75
Location
US
I have a folder on my C drive that has 130 Excel files in it. I want to write a vba script to go to the folder and get each of the Excel file names and write them to a table in Access so I can call them from another routine later. I'm using Access 2000 on xp. Again, can I do this and any help on the 'how' would be greatly appreciated.

Thanks.
 
yep no problem at all

try this

Public Sub putfilesintable()
Dim dbl_temp As Double

DoCmd.SetWarnings False
Application.FileSearch.NewSearch
Application.FileSearch.LookIn = "c:/"
Application.FileSearch.SearchSubFolders = False
Application.FileSearch.FileName = "*.*"
If Application.FileSearch.Execute() > 0 Then
For dbl_temp = 1 To Application.FileSearch.FoundFiles.Count
DoCmd.RunSQL "Insert into table1 (columnname) VALUES ('" & Application.FileSearch.FoundFiles(dbl_temp) & "')"
Next dbl_temp
End If
DoCmd.SetWarnings True
End Sub
"What a wonderfull world" - Louis armstrong
 
Chrissie1-

Thanks! Worked like a dream....you get my vote.

PerryG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top