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
|
Dim TempFile , ExcelFile , Mdp , RetourFile , objExcel , Separateur
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set fso = CreateObject("Scripting.FileSystemObject")
CurrentDirectory = fso.GetAbsolutePathName(".")
CurrentDirectory = CurrentDirectory & "\"
TempFile = CurrentDirectory & "Temp\"
Set fso = CreateObject("Scripting.FileSystemObject" )
Set f = fso.OpenTextFile(TempFile & "NomClient.txt", ForReading)
ExcelFile = f.ReadAll
Set f = fso.OpenTextFile(TempFile & "Mdp.txt", ForReading)
Mdp = f.ReadAll
ExcelFile = CurrentDirectory & "Traitement\" & ExcelFile
RetourFile = TempFile & "Retour.txt"
Separateur = " "
WScript.echo " In: " & ExcelFile
WScript.echo " Out: " & RetourFile
WScript.echo " Mdp: " & Mdp
Set objExcel = CreateObject("Excel.Application")
objExcel.Application.DisplayAlerts = True
objExcel.Application.Visible = True
objExcel.Application.Workbooks.Open ExcelFile, "3", True, , Mdp
Dim fso, fi, x, TextStreamTest
Set fso = CreateObject("Scripting.FileSystemObject")
Set fo = fso.OpenTextFile(RetourFile,ForWriting,True)
intRow = 1
ColumnCount = objExcel.Activesheet.UsedRange.Columns.count
Do Until objExcel.Cells(intRow, 1).Value = ""
TextStreamTest = ""
For x= 1 To ColumnCount
TextStreamTest = TextStreamTest & objExcel.Cells(intRow, x).Value & Separateur
Next
fo.writeline(TextStreamTest)
intRow = intRow + 1
Loop
fo.Close
objExcel.Quit |
Partager