我是Access和VBA编码的初学者,我希望将我在文件夹中的所有文件名列入我的访问表(ID(自动),文件名)?
答案 0 :(得分:0)
试试这个:
Dim F as Variant, FSO As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
Docmd.SetWarnings False
For each F in FSO.getFolder("Path to your folder").Files
Docmd.RunSQL "INSERT INTO table1 ('File Name') VALUES ('" & F & "');"
Next
Docmd.SetWarnings True
答案 1 :(得分:0)
那么,所有文件都进入一个表?
http://www.accessmvp.com/KDSnell/EXCEL_Import.htm#ImpFolderFiles
或者,所有文件都进入SEPARATE表?
http://www.accessmvp.com/KDSnell/EXCEL_Import.htm#ImpAllWkshtsFilesSepTbls