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 43 44
|
Option Explicit
' Creation du lien pour lancer Excel
Dim objExcel
Set objExcel = CreateObject("Excel.Application")
' Creation du lien pour accès Système
Dim objFso
Set objFso = CreateObject("Scripting.FileSystemObject")
' Recup argument
Dim argu0,argu1
argu0 = wscript.arguments(0)
argu1 = wscript.arguments(1)
' Ouverture du fichier txt
Dim FileRead, FileLine
Set FileRead = objFso.OpenTextFile(argu0, 1)
' Création du fichier Excel
objExcel.DisplayAlerts = False
objExcel.workbooks.Add
objExcel.Cells(1, 1).formula = "Drivers Imprimante"
Dim Compteur
Compteur = 3
' Ecriture du fichier txt dans la 1er colonne du fichier Excel
Do While FileRead.AtEndOfStream <> True
objExcel.Cells(Compteur, 1).formula = FileRead.readline
Compteur = Compteur + 1
Loop
FileRead.close
' Tri classique
Range("A3:A28").Select
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending
' Sauvegarde du fichier et sortie d'Excel
objExcel.ActiveWorkbook.SaveAs argu1
objExcel.ActiveWorkbook.Close
objExcel.Application.Quit |