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
| Option Explicit On
Const ForReading = 1
Const ForWriting = 2
Sub SupprimetTexteEndouble()
Dim oDict As Scripting.Dictionary
Dim oFSO As Scripting.FileSystemObject
Dim oFile As Scripting.TextStream
Dim maCle As String
Dim strName As String, Fichier As String
Fichier = "C:\Test_Doublon.txt"
oDict = CreateObject("Scripting.Dictionary")
oFSO = CreateObject("Scripting.FileSystemObject")
oFile = oFSO.OpenTextFile(Fichier, ForReading)
Do Until oFile.AtEndOfStream
strName = oFile.ReadLine
If Not oDict.Exists(strName) Then oDict.Add(strName, strName)
Loop
oFile.Close()
oFile = oFSO.OpenTextFile(Fichier, ForWriting)
For Each maCle In oDict.Keys
oFile.WriteLine(maCle)
Next
oFile.Close()
End Sub |
Partager