Wednesday, November 18, 2009

VB Script and excel playing aroubd...

// Following code will read and write in an excel file.


Set objXL = CreateObject("Excel.Application")
Set objWB = objXL.WorkBooks.Open("C:\Documents and Settings\nsharma\Desktop\VB scripts\test1.xls")
Set objWS = objXL.ActiveWorkBook.WorkSheets("Sheet1")
Dim CellArray()
ACount = 0
For i = 1 To 10
If objXL.Cells(i, 8).Value = "" Then
CellValue = "Empty"
objXL.Cells(i, 9).Value="Pass"
Else
CellValue = objXL.Cells(i, 8).Value
End If
ReDim preserve CellArray(ACount)
CellArray(ACount) = CellValue
msgbox(cellvalue)
ACount = ACount + 1
Next
objWB.Close
objXL.Quit

No comments:

Post a Comment

I welcome your comment, will respond and post it at the earliest:)