Record test on MS Excel
Question ID: 104224
1
0

I am unable to record against MS Excel with QTP 10. All I get is X and Y coordinates and I need to find a way to set custom coding on and MS Excel sheet that QTP is making for results.

Marked as spam
Posted by (Questions: 45, Answers: 1)
Asked on September 22, 2010 2:53 am
105 views
Answers (1)
3
Private answer

Microsoft Excel can not be recorded against directly QTP. If you want to automate testing you will have to use VB scripting level calls.

IF I understand, you are looking for code to implement code to set the colors of the cell by the value of the contents of the cell. I have written some code that will cell formatting on conditional settings. Here are the conditional settings.

* If cell value is less than 0 set cell color to red.
* If cell value is between 0 and 10 then set the cell color to yellow.
* If cell value over 10 set cell color to green.

Here is my code.


Dim oExcel 
Dim oBook 
Dim oSheet
Dim oFc 
Dim oRange 

const xlCellValue = 1  

const xlGreater = 5   
Const xlNotEqual=4  
Const xlEqual=3  
Const xlNotBetween=2  
Const xlLess=6  
Const xlGreaterEqual=7  
Const xlLessEqual=8  
Const xlBetween=1  

aSampleFile=''C:TempTestfile.xls''

Set oExcel = CreateObject(''Excel.Application'')  
Set  oBook = oExcel.Workbooks.Open(aSampleFile)  
oExcel.Visible =true  

Set oRange = oExcel.Range(''B2:B5'')  

oRange.FormatConditions.Delete  

Set oFc = oRange.FormatConditions.Add(xlCellValue, xlLess, ''0'' )  
'Red  
oFc.Interior.ColorIndex = 3  

Set oFc = oRange.FormatConditions.Add (xlCellValue, xlBetween, ''0'', ''10'')  
'yellow  
oFc.Interior.ColorIndex = 6  

Set oFc = oRange.FormatConditions.Add (xlCellValue, xlGreater, ''10'')  
'Green  
oFc.Interior.ColorIndex = 4  

Set oFc =nothing  
Set oRange=nothing  
Set oSheet =nothing  
Set oBook =nothing  
Set oExcel =nothing  
Marked as spam
Posted by (Questions: 2, Answers: 98)
Answered on September 22, 2010 3:24 am
EyeOnTesting

Welcome back to "EyeOnTesting" brought to you by Orasi Software, Inc.

X
Scroll to Top