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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
| Option Explicit
Dim objExcel, strExcelPath, objSheet, intRow, intCol
Dim objUser
DIM fso, CSVFile
Dim str
Dim csv_path, xls_path
'Bind to Excel object
On error Resume Next
Set objExcel = CreateObject("Excel.Application")
If Err.Number <> 0 Then
On Error Goto 0
Wscript.Echo "Excel application not found."
Wscript.Quit
End If
On Error Goto 0
Set fso = CreateObject("Scripting.FileSystemObject")
csv_path = "c:\csv\"
xls_path = "c:\xls\"
'***********************************************************************ok
strExcelPath = xls_path & "my_file.xls"
Set CSVFile = fso.CreateTextFile(csv_path & "my_file.CSV", True)
'Open specified spreadsheet and select the worksheet.
objExcel.WorkBooks.Open strExcelPath
Set objSheet = objExcel.ActiveWorkbook.Worksheets("Actieve Dossiers")
LOGFile.Writeline("Worksheet: Actieve Dossiers")
' Iterate through the rows of the spreadsheet after the first, until the
' first blank entry in the first column. For each row, bind to the user
' specified in the first column and set attributes.
intRow = 2
Do while objSheet.Cells(intRow, 3).text <> ""
str = ""
FOR intCol = 1 to 18
str = str & outstr(objSheet.Cells(intRow, intCOL).text) & ";"
NEXT
Str = str & "x"
On Error Resume Next
IF instr (str, "#VALEUR!") = 0 AND instr (str, "#REF!") = 0 AND instr (str, "#NUM!") = 0 AND instr (str, "#NAME?") = 0 THEN
CSVFile.Writeline(str)
nbr_rec_ok = nbr_rec_ok + 1
END IF
On error Goto 0
intRow = intRow + 1
Loop
' Close file
CSVFile.Close
' Close workbook
objExcel.ActiveWorkBook.Close
'Clean up
Set objSheet = Nothing
' quit Excel
objExcel.Application.Quit
'Clean up
Set objExcel = Nothing |
Partager