B
Bob
Let me try to clarify my issue. I need to import an
unknown number of files from an unknown location into an
access database. The code parser that generates the data
files saves them as a flat-text file, which has an .xls
extension. The Jet database engine would not allow me to
import the files using a TransferSpreadsheet command
because they are flat text file and contain no inherent
excel formatting. I could not import them as is using the
TransferText command because Jet Direct does not
consider .xls a text file. I wrote a batch file
to "move" 'c:\data\outputv3.2.xls'
to 'c:\data\outputv32.txt' then the below code goes
through the folder location and imports all of the .txt
files into the database. I have automate the below
portion and would like to automate the remaining portion
of the job. If possible I would like to know how to again
set the folder location as a variable, then the code would
go through the specified folder and take all of the .xls
files in the folder and remove any periods within the file
name and then change the extension from .xls to .txt. My
knowledge of VBA is minimal, with my only experience
coming from figuring out the below code.
Thank You
'This code is for the import button'
Private Sub Command11_Click()
Dim myfile
Dim mypath
Dim InputMsg As String
Dim InputTblName As String
Dim mytable
'The below code allows you to chose the folder where the
text files are located'
InputMsg = "Type the path of the folder that contains the
files you want to import."
mypath = InputBox(InputMsg)
'The below code allows you to set the table name for the
output'
InputTblName = "Type the name of the table you want to
create."
mytable = InputBox(InputTblName)
myfile = Dir(mypath & "*.txt")
Do While myfile <> ""
'This will import ALL the excel files (one at a time,
but automatically) in this folder.'
DoCmd.TransferText acImportDelim, "Tab_Spec", mytable,
mypath & myfile
myfile = Dir
Loop
End Sub
unknown number of files from an unknown location into an
access database. The code parser that generates the data
files saves them as a flat-text file, which has an .xls
extension. The Jet database engine would not allow me to
import the files using a TransferSpreadsheet command
because they are flat text file and contain no inherent
excel formatting. I could not import them as is using the
TransferText command because Jet Direct does not
consider .xls a text file. I wrote a batch file
to "move" 'c:\data\outputv3.2.xls'
to 'c:\data\outputv32.txt' then the below code goes
through the folder location and imports all of the .txt
files into the database. I have automate the below
portion and would like to automate the remaining portion
of the job. If possible I would like to know how to again
set the folder location as a variable, then the code would
go through the specified folder and take all of the .xls
files in the folder and remove any periods within the file
name and then change the extension from .xls to .txt. My
knowledge of VBA is minimal, with my only experience
coming from figuring out the below code.
Thank You
'This code is for the import button'
Private Sub Command11_Click()
Dim myfile
Dim mypath
Dim InputMsg As String
Dim InputTblName As String
Dim mytable
'The below code allows you to chose the folder where the
text files are located'
InputMsg = "Type the path of the folder that contains the
files you want to import."
mypath = InputBox(InputMsg)
'The below code allows you to set the table name for the
output'
InputTblName = "Type the name of the table you want to
create."
mytable = InputBox(InputTblName)
myfile = Dir(mypath & "*.txt")
Do While myfile <> ""
'This will import ALL the excel files (one at a time,
but automatically) in this folder.'
DoCmd.TransferText acImportDelim, "Tab_Spec", mytable,
mypath & myfile
myfile = Dir
Loop
End Sub