Automate Import (1 Viewer)

mathisjay

Registered User.
Local time
Today, 12:54
Joined
Apr 7, 2004
Messages
14
I have a situation where I need to be able to import a .csv file every quarter.

I know how to import the file into a table manually using the "Get External Data..." method, but I would like to be able to automate the process from the click of a button. It can be assumed the file will be located in the same place and named the same thing every time.

Is it possible to do this? How do I do this from VB code?
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 12:54
Joined
Feb 19, 2002
Messages
43,307
Import the file once more manually using the Get External Data. This time, save your selections by saving the import spec. To get to the save option, press the advanced button just before the last form of the dialog. Once you have saved the import spec, you can then import the file automatically by using the TransferText Method or Action. Read the help entries for both since the Action entry contains more detail but use the Method. If you are unfamiliar with VBA, the simplest thing to do is to create a macro that uses the TransferText Action, then convert the macro to code using the menu option. You can then copy the code into the click event of a button.
 
H

halewilson

Guest
Pat,

When I tried your method I kept getting an error dialog "The source database has no import/export specifications to copy." It didn't work out exactly the way you described but it did point me in the right direction. I was able to create a TransferDatabase macro then convert it to VBA and modify the file path's...working nicely!

Mahalo
 

Users who are viewing this thread

Top Bottom