S
sparker
Greetings Community!
I have to import hundreds upon hundreds of csv files into Access and the
files have commas randomly placed throught the data in various fields. Upon
importing the csv (Comma Seperated Value) Files, some of the data gets askew
when there is a comma in it. Any ideas on the best solution to import these
files would be greatly apreciated. I am thinking that they will need to be
opened one at a time and have the find/replace executed via Excel where , is
replaced with a Space(1)... Anybody?
Private Sub ImportBOR()
Dim strPath As String
Dim strFile As String
Dim strOldName As String
Dim strNewName As String
strPath = "C:\6-15-05 Business Objects Reports\"
strFile = Dir(strPath & "\*.csv")
Do While strFile <> ""
"I believe that maybe I need code placed here to open each file and perform
a find/replace on all of the commas?"
DoCmd.TransferText acImportDelim, "BOR_ImportSpec", "tblNewBOR", strPath &
strFile
strOldName = strPath & "\" & strFile
strNewName = strPath & "\" & Left(strFile, Len(strFile) - 3) & "sav"
Name strOldName As strNewName
strFile = Dir(strPath & "\*.csv")
Loop
strFile = Dir(strPath & "\*.sav")
Do While strFile <> ""
strOldName = strPath & "\" & strFile
strNewName = strPath & "\" & Left(strFile, Len(strFile) - 3) & "csv"
Name strOldName As strNewName
strFile = Dir(strPath & "\*.sav")
Loop
End Sub
I have to import hundreds upon hundreds of csv files into Access and the
files have commas randomly placed throught the data in various fields. Upon
importing the csv (Comma Seperated Value) Files, some of the data gets askew
when there is a comma in it. Any ideas on the best solution to import these
files would be greatly apreciated. I am thinking that they will need to be
opened one at a time and have the find/replace executed via Excel where , is
replaced with a Space(1)... Anybody?
Private Sub ImportBOR()
Dim strPath As String
Dim strFile As String
Dim strOldName As String
Dim strNewName As String
strPath = "C:\6-15-05 Business Objects Reports\"
strFile = Dir(strPath & "\*.csv")
Do While strFile <> ""
"I believe that maybe I need code placed here to open each file and perform
a find/replace on all of the commas?"
DoCmd.TransferText acImportDelim, "BOR_ImportSpec", "tblNewBOR", strPath &
strFile
strOldName = strPath & "\" & strFile
strNewName = strPath & "\" & Left(strFile, Len(strFile) - 3) & "sav"
Name strOldName As strNewName
strFile = Dir(strPath & "\*.csv")
Loop
strFile = Dir(strPath & "\*.sav")
Do While strFile <> ""
strOldName = strPath & "\" & strFile
strNewName = strPath & "\" & Left(strFile, Len(strFile) - 3) & "csv"
Name strOldName As strNewName
strFile = Dir(strPath & "\*.sav")
Loop
End Sub