Edit font color

Here is a tip how to edit font color.

 

Source code

function setFontColor() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sh = ss.getActiveSheet();
  var color = "#cfe31c";

  ss.getActiveRange().setFontColor(color);

  var hd = "New Font Color: ";
  var nw = ss.getActiveRange().getFontColor();

  Browser.msgBox(hd + nw);
}

 

Format

RangeObject.setFontColor(color)

 

Parameters

color … Set the color code in string format.

 

Responses

None

 

It can also set color name to the parameter

function setFontColor2() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sh = ss.getActiveSheet();
  var color = "red";

  ss.getActiveRange().setFontColor(color);

  var hd = "New Font Color2: ";
  var nw = ss.getActiveRange().getFontColor();

  Browser.msgBox(hd + nw);
}

 

How to get a range’s object?

Please refer the following tips.

Get an active range object

Get a range object by row & column number

Get a range object by address

 

How to get font color?

Please refer the following tip.

Get font color

Leave a Comment