Hello I try to detect specific string in my google doc and set it in "bold". Ive tried this :
function bold() {
var body = DocumentApp.getActiveDocument().getBody();
var foundElement = body.findText("Câbles");
while (foundElement != null) {
// Get the text object from the element
var foundText = foundElement.getElement().asText();
// Change the weight
foundText.setFontWeight("bold");
// Find the next match
foundElement = body.findText("Câbles", foundElement);
}
}
The script return me an error : TypeError: Fonction setFontWeight not found in Text object.
Can you help me? Thanks.
EDIT>
Ive tried using this, but the bold style was now applied to the whole paragraph not only the text string...
function bold() {
var body = DocumentApp.getActiveDocument().getBody();
var foundElement = body.findText("test");
while (foundElement != null) {
// Get the text object from the element
var foundText = foundElement.getElement().asText();
// Set Bold
foundText.setBold(true);
// Find the next match
foundElement = body.findText("test", foundElement);
}
}