D
doran_doran via AccessMonster.com
HI,
I have few hundreds of excel files (with and without headers) but the same
type of data (column a to m) that I need to import into a table (tblMaster).
I was trying to use this method to import excel files. but nothng happens
when i use following code on a button and click on the button. Please advise.
Thanks
Private Sub cmdImport_Click()
Dim MyFile, MyPath, MyName, fs
MyFile = Dir("L:\Conversions\Master Trans\1\*.xls")
Set fs = CreateObject("Scripting.FileSystemObject")
Do While MyName <> ""
DoCmd.DeleteObject acTable, "tblMaster"
'DoCmd.Transfertext acImportdelim, , "NewData", myfile
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel97, "tblMaster"
MsgBox "import complete"
'DoCmd.OpenQuery "Append NewData to your final output"
fs.CopyFile MyFile, "L:\Conversions\Master Trans\1\Done\"
MsgBox "file have been copied to done directory"
'fs.deletfile myfile
MyName = Dir
Loop
End Sub
I have few hundreds of excel files (with and without headers) but the same
type of data (column a to m) that I need to import into a table (tblMaster).
I was trying to use this method to import excel files. but nothng happens
when i use following code on a button and click on the button. Please advise.
Thanks
Private Sub cmdImport_Click()
Dim MyFile, MyPath, MyName, fs
MyFile = Dir("L:\Conversions\Master Trans\1\*.xls")
Set fs = CreateObject("Scripting.FileSystemObject")
Do While MyName <> ""
DoCmd.DeleteObject acTable, "tblMaster"
'DoCmd.Transfertext acImportdelim, , "NewData", myfile
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel97, "tblMaster"
MsgBox "import complete"
'DoCmd.OpenQuery "Append NewData to your final output"
fs.CopyFile MyFile, "L:\Conversions\Master Trans\1\Done\"
MsgBox "file have been copied to done directory"
'fs.deletfile myfile
MyName = Dir
Loop
End Sub