Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

lire et ecrire dans le bloc-notes avec excel

3 réponses
Avatar
michel thiviers
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

3 réponses

Avatar
FdeCourt
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.
Avatar
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.
Avatar
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.