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
Loop
myExcel.ActiveWorkbook.Close
myExcel.Application.Quit
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
Loop
myExcel.ActiveWorkbook.Close
myExcel.Application.Quit
Comments
Post a Comment
Your comments will be reviewed and then published !