Forum Discussion

mky_87's avatar
mky_87
Occasional Contributor
13 years ago

EXCEl cell font color settings problem

TestComplete:C#Script




How EXCEl cell font color attribute set.










Give a specific example?

1 Reply

  • AlexeyK's avatar
    AlexeyK
    SmartBear Alumni (Retired)

    Hi,


    You can record a test that will change the color from the Excel UI and explore the recorded test commands.


    An alternative approach is to work with Excel via COM. For more information on this and on the Excel object model, see the Excel documentation. Here is a code snippet that demonstrates how to change the color of the current active cell via COM:




    // This code assumes you have Excel launched and some workbook opened in it.


    // Connect to Excel via COM

    var ExcelApp = Sys["OleObject"]("Excel.Application");


    // Red

    ExcelApp["ActiveCell"]["Font"]["Color"] = 0x0000FF;


    // Green

    // ExcelApp["ActiveCell"]["Font"]["Color"] = 0x00FF00;


    // Blue

    // ExcelApp["ActiveCell"]["Font"]["Color"] = 0xFF0000;