Hope all of you are doing well....:)
Here i am providing an Userdefined Function for displaying the cell colors of Excel document.
' Function Defination:
Function ExcelCellColors_display(FilePath)
Dim xl
Set xl=CreateObject("Excel.Application")
xl.visible=True
xl.WorkBooks.Open FilePath
' Retrieving the rowcount used
rc=xl.Activesheet.usedrange.rows.count
' Clearing the existing Data in excel (If any)
For j=1 to rc
xl.Cells(j,1).interior.colorindex=null
xl.Cells(j,1).value=Null
xl.Cells(j,2).value=Null
xl.Cells(j,2).interior.colorindex=null
Next
xl.cells(1,1).value="Color"
xl.cells(1,2).value="Color Index"
' Filling the colors & colorindex values
For i=2 to 56
xl.Cells(i,1).interior.colorindex=i-1
xl.Cells(i,2).value=xl.Cells(i,1).interior.colorindex
Next
xl.ActiveworkBook.Save
xl.ActiveworkBook.Save
wait(1)
xl.Application.quit
Set xl=nothing
End Function
'Function Declaration/Calling:
Call ExcelCellColors_display( "D:\Documents and Settings\Sree\Desktop\Excel_colors.xls")
Output:
you are good in QTP!!!!!!!!
ReplyDelete