SilkTest Classic: Verifying the BackGround Color of Excel Cells

SilkTest Classic: Verifying the BackGround Color of Excel Cells

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.


Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2014-10-07 19:06
Updated by:
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.