Bonjour,
j'essaiye de lire et ecrire du texte dans le bloc note à partir d'excel.
J'arrive à l'ouvrir pas de probleme, mais pour lire chaque ligne et les
mettre en colonne, je sèche.
Merci d'avance à celui qui pourra m'aider.
Michel
Salut, Quel est l'objectif ? Lire dans un fichier txt ? Si c'est le cas, pas besoin du blocnote (en lecture seule):
Open "CXXX" For Input Access Read As 1 Do While Not EOF(1) Line Input #1, TextLine Loop
Cordialement,
F.
FdeCourt
Salut,
Les macros ci-dessous liste l'ensemble des fichiers TXT dans le repertoire du classeur, et alimentent la colonne A des valeurs de ces fichiers :
Sub Lire(quoi As String) Open quoi For Input Access Read As 1 Do While Not EOF(1) Line Input #1, TextLine With Sheets("1") .Cells(.Cells(65536, 1).End(xlUp).Row + 1, 1) = TextLine End With Loop Close #1 End Sub
Sub TouslesFichierTXT() Dim chemin As String Dim i As Integer chemin = ActiveWorkbook.Path
With Application.FileSearch .NewSearch .LookIn = chemin & "" .SearchSubFolders = Fasle .Filename = "*.txt" End With
With Application.FileSearch If .Execute() > 0 Then For i = 1 To .FoundFiles.Count Lire .FoundFiles(i) Next i End If End With
End Sub
Cordialement,
F.
Salut,
Les macros ci-dessous liste l'ensemble des fichiers TXT dans le
repertoire du classeur, et alimentent la colonne A des valeurs de ces
fichiers :
Sub Lire(quoi As String)
Open quoi For Input Access Read As 1
Do While Not EOF(1)
Line Input #1, TextLine
With Sheets("1")
.Cells(.Cells(65536, 1).End(xlUp).Row + 1, 1) = TextLine
End With
Loop
Close #1
End Sub
Sub TouslesFichierTXT()
Dim chemin As String
Dim i As Integer
chemin = ActiveWorkbook.Path
With Application.FileSearch
.NewSearch
.LookIn = chemin & ""
.SearchSubFolders = Fasle
.Filename = "*.txt"
End With
With Application.FileSearch
If .Execute() > 0 Then
For i = 1 To .FoundFiles.Count
Lire .FoundFiles(i)
Next i
End If
End With
Les macros ci-dessous liste l'ensemble des fichiers TXT dans le repertoire du classeur, et alimentent la colonne A des valeurs de ces fichiers :
Sub Lire(quoi As String) Open quoi For Input Access Read As 1 Do While Not EOF(1) Line Input #1, TextLine With Sheets("1") .Cells(.Cells(65536, 1).End(xlUp).Row + 1, 1) = TextLine End With Loop Close #1 End Sub
Sub TouslesFichierTXT() Dim chemin As String Dim i As Integer chemin = ActiveWorkbook.Path
With Application.FileSearch .NewSearch .LookIn = chemin & "" .SearchSubFolders = Fasle .Filename = "*.txt" End With
With Application.FileSearch If .Execute() > 0 Then For i = 1 To .FoundFiles.Count Lire .FoundFiles(i) Next i End If End With
End Sub
Cordialement,
F.
michel thiviers
Merci cordialement michel "FdeCourt" a écrit dans le message de news:
Salut,
Les macros ci-dessous liste l'ensemble des fichiers TXT dans le repertoire du classeur, et alimentent la colonne A des valeurs de ces fichiers :
Sub Lire(quoi As String) Open quoi For Input Access Read As 1 Do While Not EOF(1) Line Input #1, TextLine With Sheets("1") .Cells(.Cells(65536, 1).End(xlUp).Row + 1, 1) = TextLine End With Loop Close #1 End Sub
Sub TouslesFichierTXT() Dim chemin As String Dim i As Integer chemin = ActiveWorkbook.Path
With Application.FileSearch .NewSearch .LookIn = chemin & "" .SearchSubFolders = Fasle .Filename = "*.txt" End With
With Application.FileSearch If .Execute() > 0 Then For i = 1 To .FoundFiles.Count Lire .FoundFiles(i) Next i End If End With
End Sub
Cordialement,
F.
Merci
cordialement
michel
"FdeCourt" <fdecourt@gmail.com> a écrit dans le message de
news:4c4dde16-f639-4efe-8d9e-becc6077656b@w13g2000prm.googlegroups.com...
Salut,
Les macros ci-dessous liste l'ensemble des fichiers TXT dans le
repertoire du classeur, et alimentent la colonne A des valeurs de ces
fichiers :
Sub Lire(quoi As String)
Open quoi For Input Access Read As 1
Do While Not EOF(1)
Line Input #1, TextLine
With Sheets("1")
.Cells(.Cells(65536, 1).End(xlUp).Row + 1, 1) = TextLine
End With
Loop
Close #1
End Sub
Sub TouslesFichierTXT()
Dim chemin As String
Dim i As Integer
chemin = ActiveWorkbook.Path
With Application.FileSearch
.NewSearch
.LookIn = chemin & ""
.SearchSubFolders = Fasle
.Filename = "*.txt"
End With
With Application.FileSearch
If .Execute() > 0 Then
For i = 1 To .FoundFiles.Count
Lire .FoundFiles(i)
Next i
End If
End With
Merci cordialement michel "FdeCourt" a écrit dans le message de news:
Salut,
Les macros ci-dessous liste l'ensemble des fichiers TXT dans le repertoire du classeur, et alimentent la colonne A des valeurs de ces fichiers :
Sub Lire(quoi As String) Open quoi For Input Access Read As 1 Do While Not EOF(1) Line Input #1, TextLine With Sheets("1") .Cells(.Cells(65536, 1).End(xlUp).Row + 1, 1) = TextLine End With Loop Close #1 End Sub
Sub TouslesFichierTXT() Dim chemin As String Dim i As Integer chemin = ActiveWorkbook.Path
With Application.FileSearch .NewSearch .LookIn = chemin & "" .SearchSubFolders = Fasle .Filename = "*.txt" End With
With Application.FileSearch If .Execute() > 0 Then For i = 1 To .FoundFiles.Count Lire .FoundFiles(i) Next i End If End With