Set myexcel = createobject("excel.application") 'create an excelsheet object
Set myfile = myexcel.workbooks.open("C:\test1.xls") 'create an excel sheet in a specified folder
myexcel.visible = true
Set mysheet = myfile.worksheets("sheet1") 'assign the sheet in excel
Row_cnt = mysheet.usedrange.rows.count
For i = 2 to Row_cnt
FirstName = mysheet.cells(i,"A")
LastName = mysheet.cells(i,"B")
Set FirName = description.Create
FirName("name").value = "firstName"
Set LasName = description.Create
LasName("name").value = "lastName"
set erfir = description.create
erfir("outertext").value= "Enter valid First Name"
erfir("class").value = "errmessage"
erfir("Class Name").value = "WebElement"
Browser(hmbro).page(hmpage).webedit( FirName).set FirstName
If Browser(hmbro).page(hmpage).WebElement(erfir).Exist Then
print "Invalid First name: " & FirstName
mysheet.cells(i,"A").font.color =vbred
else
mysheet.cells(i,"A").font.color = vbgreen
End If
Browser(hmbro).page(hmpage).webedit(LasName).Set LastName
set erlast = description.create()
erlast("outertext").value= "Enter valid Last Name"
erlast("class").value = "errmessage"
erlast("Class Name").value = "WebElement"
If Browser(hmbro).page(hmpage).WebElement(erlast).Exist Then
print "Invalid Last name: " & LastName
mysheet.cells(i,"B").font.color = vbred
else
mysheet.cells(i,"B").font.color =vbgreen
End If
Next
myexcel.quit
set myexcel = nothing
2) Compare two excel sheets:
Set a = createobject ("excel.application")
a.visible= True
Set b = a.workbooks.open ("D:\test1.xls")
Set c = a.workbooks.open ("D:\test2.xls")
Set d = b.worksheets (1)
Set e = c.worksheets (1)
For each cell in d.usedRange
If cell.value<>e.range (cell.address).value Then
cell.interior.colorindex=3
cell.font.color = vbgreen
else
cell.interior.colorindex=5
cell.font.color = vbred
End If
Next
a.quit ' If u want to close the excel then use this syntax
Set a=nothing
3) Create an Excel, Edit and provide a hyperlink to the edited text
Set excel = createobject("excel.application")
excel.visible = true
Set myfile = excel.workbooks.add
Set sheet = excel.worksheets(1)
sheet.cells(1,1) = "testing"
Set range = excel.range("A1")
Set hyperlink = sheet.hyperlinks.add(range,"http://www.ssofttesting.blogspot.com")