Reading an Excel in VBScript

Below is a piece of code which can be used to read excel sheet and the values in the row or column.
Option Explicit
Dim myExcel,strExcelPath,objSheet
Dim intRow,strRow2Col1,strRow2Col2

Set myExcel = CreateObject("Excel.Application")
strExcelPath = "C:\Book2.xls"

myExcel.WorkBooks.Open strExcelPath
Set objSheet = myExcel.ActiveWorkbook.Worksheets(1)

'Assuming that the first row will contain the name of the column
intRow = 2
Do While objSheet.Cells(intRow, 1).Value <> ""
    strRow2Col1 = objSheet.Cells(intRow, 1).Value
    strRow2Col2 = objSheet.Cells(intRow, 2).Value
'Increment the control to the next row
    intRow = intRow + 1



Popular posts from this blog

Defect Tracking System – Wastage of Money & Time ???

The 3 qualities that will always help you become better at almost anything…

Test Case Paths : Happy, Sad & Bad