Never have worked with inserting info directly into an excel file, but here's how to do it with access. Assuming you have a Database and table with column named "fileName" created already.
It may be ugly, but it works!Code:' define the necessary variables strPathToFolder = ' insert folder path strDBPath = ' insert path to database strTableName = ' insert table name ' instantiate all necessary items Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFolder = objFSO.GetFolder(strPathToFolder) Set objFolderContents = objFolder.Files Set objConnection = CreateObject("Adodb.Connection") Set objRecordset = CreateObject("Adodb.Recordset") ' open data objConnection.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & strDBPath objRecordset.Open strTableName, objConnection, 3, 3, 2 ' now loop through the contents of the folder For Each objFile in objFolderContents strFileName = objFile.Name ' and add each to the table objRecordset.AddNew objRecordset("fileName") = strFileName objRecordset.Update Next ' clean up Set objRecordset = Nothing Set objConnection = Nothing Set objFSO = Nothing Set objFSO = Nothing


Reply With Quote
