Macro Transfer Text Function

  • Thread starter Thread starter wycrbg
  • Start date Start date
W

wycrbg

Can you teach me how I can make the "File Name" imbed a
variable path name which I can concatenate to my desired
filename. I have the path (e.g. c:\temp\work) hardcoded in
te "File Name" and every time a client wants a different
path I have to change one by one for all the macros I had
made. Many thanks for your help.
 
Use VBA code.
Macros are a very poor substitute and code is not that hard to learn.
Just read from top to bottom and look up anything you don't understand.

How to Import all Files in a Folder:

Private Sub btnImportAllFiles_Click()
'procedure to import all files in a directory and delete them.
'assumes they are all the correct format for an ASCII delimited import.
Dim strfile As String

ChDir ("c:\MyFiles")
strfile = Dir("FileName*.*")
Do While Len(strfile) > 0
DoCmd.TransferText acImportDelim, "ImportSpecName", "AccessTableName",
"c:\MyFiles\" & strfile, True
'delete the file (consider moving it to an Archive folder instead.)
Kill "c:\MyFiles\" & strfile
strfile = Dir
Loop

End Sub
 
Back
Top