Importer fichier TXT
Importer ligne par ligne un fichier texte (.txt)
Lecture de chaque ligne d'un fichier texte et importation dans un champ d'une table.
Sub ImportTXT()
Dim txtLine As String
Dim LeFichier As String
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim F As Integer
LeFichier = "c:\cheminfichier.txt"
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("LaTable", dbOpenDynaset)
F = FreeFile
Open LeFichier For Input As #F
Line Input #F, txtLine
Do While Not EOF(F)
Line Input #F, txtLine
With rst
.AddNew
.Fields("LeChamp").Value = txtLine
.Update
End With
Loop
Close #F
rst.Close
Set dbs = Nothing
Set rst = Nothing
End Sub
Dernière modification : 19/02/2010 18:58
Catégorie : Les mémos - Fichiers
Page lue 8187 fois