View Full Version : User definined filename for DoCmd.TransferSpreadsheet?


aranj
07-16-2004, 03:34 AM
My colleagues can't be trusted to import the data into a table using file->get external data -> import!

Everything works using:

DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "tablename", "Excelfilename", True

But can I get a dialog box up for "Excelfilename" so that they can browse to a file? Or is there another way?

Many thanks.

Pat Hartman
07-16-2004, 10:43 AM
This sample that I posted should show you how to use the common dialog.

Common dialog sample (http://www.access-programmers.co.uk/forums/showthread.php?s=&threadid=50651)

aranj
07-16-2004, 10:50 AM
Many thanks, as always.
The same old problem - if I knew what I was looking for (common dialog) I could've found it myself!
Thanks once again.

niftysam
07-29-2004, 08:04 AM
Is there a way to create the table according to the Excel fields and then import the file from excel? My excel files will never have the same fields. Thanks

Pat Hartman
07-29-2004, 02:39 PM
When you import a spreadsheet, you have the option of creating a new table or appending to an existing one.

niftysam
07-30-2004, 02:50 PM
yes, but I need it dynamically :)

Pat Hartman
07-30-2004, 08:44 PM
What is it that you need to be dynamic? If you're talking about the table name, use a variable rather than hardcoding it.

strTableName = some value
strExcelFileName = some value
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, strTableName , strExcelFileName , True

niftysam
08-02-2004, 08:10 AM
Pat, Thanks so much!!! I was thinking I needed to custom code adding a blank table with field definitions and then update this table.