Linking all files

DaLiMan

Active Member
Joined
Jun 1, 2004
Messages
295
Hi,

I'm looking for a way to automate the task of linking files (especially NEW files in the directory)
Is there a way to create a macro or something that checks all .txt files in a specific directory and compares if they are already linked.
If they are not linked do this automatically in a new table in the Access Database.

Sinds I have no way of telling when a new file is added in this directory I need to check all by hand. :cry: Now I'm not very happy with this as you can understand. I really hope someone can help me with this.
 
Remove those lines.
I left in some commented out lines (that's the ' character) and that particular line isn't needed at all for it to run.

Mike
 
Upvote 0

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Wow, it works.
This is really cool Mike.

Only I found the existing tables are being duplicated like:
Test.xls
Test.xls1
Test.xls2
etc...

And can this also be done with TXT files.
I run into the problem that the script didn't recognize TXT files.
I tried to change "DoCmd.TransferSpreadsheet" in the Import function but due to my limited understanding without succes.

You're really helping me out here !!! Thanx !!!
 
Upvote 0
Text file import uses a slightly different command.

spec is an import specification.
tblA is the name of hte table (after import in Access)
dstFile is the full path to the file

Import specifications are a wonderful thing in Access. With a Fixed import, it allows you to specify the exact size and composition of a given field. You can force dates into Text, for example, without allowing Access to 'guess'

They're built by importing a text file manually, and (BEFORE DONE) hitting the Advanced button on the bottom left hand corner of the Import Wizard. You can then save a specification file (or resave over old names or delete ones no longer in use)

Code:
Sub ImportRoutine(spec As String, tblA As String, dstFile As String)

  DoCmd.TransferText acImportFixed, spec, tblA, dstFile

End Sub
 
Upvote 0
OK, so TXT files are a different ballgame......

I'll just keep it at spreadsheets which work fine.
Thanx Mike for all your time and help.

Greetings,
Daniel
 
Upvote 0

Forum statistics

Threads
1,221,832
Messages
6,162,254
Members
451,757
Latest member
iours

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top