1
votes

How can the background color of a document element be removed (aka set to null)?

I've tried setting the value to "null", however, the system gives me this error: "We're sorry, a server error occurred. Please wait a bit and try again. (line 14)"

If I comment line 14 (activeSel.setBackgroundColor) out the script works fine

function clearDoc(){
  var doc = DocumentApp.openById(DOC1Id);
  var activeSel = doc.getActiveSection().getParagraphs()[2];
  var attr = activeSel.getAttributes(); // BACKGROUND_COLOR = "#ff0000"
  activeSel.setBackgroundColor(null); // errors out
  return
}
2
I tried setAttributes(object) as recommended in the documentation but without any result either...It throws an error Exception : null - Serge insas
Thanks for taking a look Serge :) - propjk007

2 Answers

1
votes

Setting BACKGROUND_COLOR to null (or using setBackgroundColor) now clears the background color. The example given above no longer errors out.

0
votes

Have you tried setting the background color to white ("#ffffff")?