Change Text Colors
HTML-код
- Опубликовано: 16 сен 2024
- Change all of a specific color text to another specific color.
Sheet (to copy)
docs.google.co...
Script:
function changeColors() {
const sh = SpreadsheetApp.getActiveSpreadsheet();
const ss = sh.getActiveSheet();
const oldColors =["#99ff66","#f4cccc"];
const newColors = ["#38761d","#990000"];
let r = ss.getRange(2,1,5,2);
let fonts = r.getFontColors();
for (let i in fonts){
for (let j in fonts[i]){
if (oldColors.indexOf(fonts[i][j]) != -1)
fonts[i][j] = newColors[oldColors.indexOf(fonts[i][j])];
}
}
r.setFontColors(fonts);
}
Connect with me:
• spencer.farris@gmail.com
• spencerfarris.me
• www.linkedin.com/in/spencer-farris/
• Twitter @FarrisSpencer
• Google Product Expert support.google.com/docs/profile/12305
Hey Spencer, thanks for making this. Is there a way to do the same thing for Google Docs?
Theoretically... but it's way harder finding specific elements in Docs.