At work we use Google Spreadsheets for mutual communication. Everyone has their own textcolor that they are allowed to work in the document.
But everyone forgets to customize the text color. Since it is not convenient to select a textcolor each time we want to work in Google Spreadsheeds, we had the idead to automate this with Google Script Editor.
function setFontColor(range, fontc) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var cell = sheet.getRange(range);
cell.setFontColor(fontc);
}
function onEdit() {
var email = Session.getActiveUser().getEmail();
if (email == "[email protected]"){
setFontColor(".getActiveCell()", "#FF8800");
}
if (email == "[email protected]"){
setFontColor(".getActiveCell()", "#0099CC");
}
if (email == "[email protected]"){
setFontColor(".getActiveCell()", "#9933CC");
}
if (email == "[email protected]"){
setFontColor(".getActiveCell()", "#CC0000");
}
}
I came up with this script since I couldn't find anything else. Unfortunately this isn't working. Can someone help me to make it work or give me a link to a existing script?
It would really help me! And probably allot of others.
I found the solution and wanted to share it for anyone who might think it would be helpfull!
function onEdit() {
var ActiveSheet = SpreadsheetApp.getActiveSheet();
var ActiveRow = ActiveSheet.getActiveRange().getRow();
var ActiveCell = ActiveSheet.getActiveCell();
var email = Session.getActiveUser().getEmail();
if (email == "[email protected]"){
ActiveCell.setFontColor("#FF8800");
}
if (email == "[email protected]"){
ActiveCell.setFontColor("#0099CC");
}
if (email == "[email protected]"){
ActiveCell.setFontColor("#9933CC");
}
if (email == "[email protected]"){
ActiveCell.setFontColor("#CC0000");
}
}