1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| '<<<<<<< LECTURE d'un fichier >>>>>>>>>>>>
'déclaration file system object
Dim fso
'instanciation
Set FSO = CreateObject("Scripting.FileSystemObject")
'on instance le fichier texte
Set Ftxt = FSO.OpenTextFile("Monchemin")
'on parcours chaque ligne du fichier texte
Do While Not Ftxt.AtEndOfStream
MaVariable = Ftxt.Readline
'....... <- votre code ici pour traiter chaque ligne
Loop
Ftxt.Close
'<<<<<<< ECRITURE dans un fichier >>>>>>>>>>>>
'déclaration file system object
Dim fso
'instanciation
Set FSO = CreateObject("Scripting.FileSystemObject")
'on instance le fichier texte dans lequel on veut ecrire
Set Ftxt = FSO.createTextFile("Monchemin",true) 'true=ecrase
'On ecrit ce que l'on veut dans le fichier
Ftxt.writeline ("Mon texte à écrire ou ma Variable texte")
'Utilisation de With .. End With pour écrire plusieurs lignes.
With Ftxt
.writeline("Mon texte à écrire ou ma Variable texte")
.writeline("Mon texte à écrire ou ma Variable texte")
.writeline("Mon texte à écrire ou ma Variable texte")
End With
Ftxt.Close |
Partager