Reputation: 1427
I'm trying to set the border color to white for every table in my document using the script below, but even though getColor()
returns '#ffffff'
for each table, table borders remain the same in the actual document.
How can I get it done? And why does the code fail?
function whiteBorders() {
var body = DocumentApp.getActiveDocument().getBody();
var tables = body.getTables();
for(var i in tables) {
tables[i].setBorderColor('#ffffff');
}
}
Upvotes: 2
Views: 2300
Reputation: 17651
I think if you check the logs, you'll see errors on this line:
var body = DocumentApp.getActiveDocument().getBody();
I'm not an expert to give you the in-depth explanation of what caused this but I rectified your code and was able to successfully change the border colors in my Google Docs.
This is all the code:
function changeBorderColor() {
var doc = DocumentApp.openById('ENTER_DOCUMENT_ID');
var body =doc.getBody();
var tables = body.getTables();
for(var i in tables) {
tables[i].setBorderColor('#00ff00');
}
}
This set my table borders to Green. Hope that helps :)
Upvotes: 1