NOTICE: Our Community is moving. Get more information. Updated information on a New Login Process
It is not possible to directly return the background color of cells within Excel spreadsheets by using either object recognition or the DB_Tester functions as neither approach provides access to a colour property that can be interrogated. However, in Excel it is possible to define a VBA function that extracts the background colour of a cell and populates another cell with that colour's numeric value. The steps to create the function in your Excel Workbook are as follows:
1. Press <Alt+F11> to launch the Visual Basic Editor, and click 'Insert > Module' from the menubar.
2. Type the following VBA code to extract the background ColorIndex value of a specified cell:
3. Press Alt+F11 to switch back to the Worksheet.
4. Select a cell to hold the color value and call the BGCol() function - specifying the row and column of the cell that you want to extract the background colour from. e.g:
Please note that this solution is only viable if the cell does not have any other vba modules attached to it.
Assuming this is the case; the color values can be extracted in your SilkTest Classic script using low level events to copy the value to clipboard or alternatively by querying the Excel file directly through the DB_Tester functions. Further information on these functions can be found in the SilkTest Classic Help documentation.
Here you can see the 56 colors that are available through the Excel ColorIndex property.