Use a Cmd button to import Excel spreadsheet?

andreas_udby

Registered User.
Local time
Today, 19:55
Joined
May 7, 2001
Messages
76
Okay, I know how to import an Excel spreadsheet using the "File... " "Get External Data" method, but I'd like to provide the users of this app with a button that will launch that same process, rather than making them go through the text menus. Does anyone know how to do this through a command button?

Thanks,
Andreas
 
Put this in the on click event:

Code:
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel97, "MyTable", "c:\MyExcelFileName.xls", True

True refers to whether the spreadsheet has field names. The field names need to match the field names in the table.

Hope this helps
 
Wow, that works great! Only one question: can I change the code snippet so that it lets the user browse for the new spreadsheet, rather than have it be in a specific place with a specific name?

Thanks again,
Andreas
 
ok just to let you know, yes there is a way, becasue my database does it. but i was provided the code by someone else and its mixed in with loads more code. i have tried to trace where it happens in the code and got this where it opens the box (using debug

fResult = ts_apiGetOpenFileName(tsFN)

i have attached the code that contains that line, but there are 3 more modules, i think this one does do it, i jus havnt worked out exactly how.

i just hope u know alot about VB, im a C++ person my self with quite a bit of VB knowledge but where i diddnt write the code, i havnt got the time to go through it, hope u figure it.

DAL
 

Attachments

Users who are viewing this thread

Back
Top Bottom