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
| FichierSource = "c:\log.txt" 'c'est un exemple à remplacer par ton fichier
Const ForReading = 1
Set objExcel = CreateObject("Excel.Application")
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Verif fichier source
If objFSO.FileExists(Fichiersource) Then
Set objTextFile = objFSO.OpenTextFile(Fichiersource, ForReading)
Else
Wscript.Echo "Fichier : """ & Fichiersource & """ introuvable, tâche annulée"
Wscript.quit
End If
'Remplit Dictionnaire de données (empeche les doublons)
Do Until objTextFile.AtEndOfStream
strNextLine = objTextFile.Readline
objDictionary.Add strNextLine, strNextLine
Loop
objTextFile.Close
'Ouverture excel
objExcel.Visible = True
objExcel.Workbooks.Add()
'Remplissage excel
ligne = 1
colonne = 1
For Each strKey in objDictionary.Keys
ligne = 1
colonne = colonne +1
arrList1 = Split(objDictionary.item(strKey) , ";")
objExcel.Cells(ligne , colonne ).Value = arrList1(0)
colonne = colonne +1
objExcel.Cells(ligne , colonne ).Value = arrList1(1)
colonne = colonne +1
objExcel.Cells(ligne , colonne ).Value = arrList1(2)
'après ca dépend combien de champs il y a, dans cet exemple il y en a 3
Next |
Partager