View Full Version : Importing .XLS files


Soma_rich
06-05-2007, 07:12 AM
I had a look at the search results and I couldnt see what I needed. I want to import spreadsheets and create the tables using the files names of the XLS. This is what I have so far anyone able to help?

Private Sub Command0_Click()

DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel97, StrFileName, "C:\Temp\CI\*.xls", True

End Sub

llkhoutx
06-05-2007, 09:57 AM
StrfileName has no value.

MStCyr
06-06-2007, 06:25 AM
Why don't you just link to the file???

Soma_rich
06-06-2007, 06:49 AM
because I am import 60+ files with differant file names and the 60 will change each month.

boblarson
06-06-2007, 06:56 AM
Private Sub Command0_Click()

DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel97, StrFileName, "C:\Temp\CI\*.xls", True

End Sub

Okay, comments about this:

1. acSpreadsheetTypeExcel97 (doesn't exist as an option for me) acSpreadsheetTypeExcel8 would be the choice if you are using 97.
2. As mentioned by llkhoutx, StrFileName doesn't seem to have a value and that should be the table name that you are importing to.
3. "C:\Temp\CI\*.xls" is not a valid file path. You have to tell it what file you are importing, you can't use an asterisk. You could do something like: "C:\Temp\CI\" & strFile & ".xls" if you assigned a value to strFile.