patriciaevans
08-28-2007, 05:50 PM
I new to creating VBA code. I have over 200 Excel files I want to import them in to an access database (1 table) appending the files... I want to be able to click on a button and import the files. Help please.
|
View Full Version : Creating an API Call to import "xls" files. patriciaevans 08-28-2007, 05:50 PM I new to creating VBA code. I have over 200 Excel files I want to import them in to an access database (1 table) appending the files... I want to be able to click on a button and import the files. Help please. Pat Hartman 08-28-2007, 07:32 PM Use the TransferSpreadsheet Method to automate this process. If this is a one-time import, create code that loops through the directory containing all the workbooks and import them one at a time. If you want to allow the user to import files individually, use the common dialog to allow the user to browse to the file he wants to import. patriciaevans 08-29-2007, 04:14 AM I can use transferspreadsheet method for one file. Don't know how to make in work for all files in the directory. I'm a newbie! Is that VBA Code or a macro... and if so am I'm creating the code on a command onclick event? Assistance is appreciated. Moniker 08-29-2007, 08:14 AM ... create code that loops through the directory containing all the workbooks and import them one at a time. If you want to allow the user to import files individually, use the common dialog to allow the user to browse to the file he wants to import. He just told you that it's VBA code to do this, as in how to loop through all the files in a directory. Since you're new, search the forum for FileDialog object to see how to loop through all the files (workbooks in your case) in a specific directory and perform an action (import them in your case) on each one. This is not difficult to do, but depending on how green you are, this may seem overwhelming at first. Generically written: 1) Allow user to select directory using the FileDialog object. (Hint: Either use the API or set a reference to the Microsoft Office X.0 Object Library to expose the FileDialog object.) 2) In that directory, use the file count property to determine the number of files. 3) As you step through each filename, make sure it ends in .xls so that you know it's an Excel file. 4) For each file, use the TransferSpreadsheet method to append it to a table of your choice. And that's it. |