I am using google apps scripts and I am trying to have a button that pastes "Motion—_____ moved and _____ seconded that _____." in a google doc. To only highlight the first six letters I have used the below code but I keep getting this error message:
Exception: The parameters (number,number,(class)) don't match the method signature for DocumentApp.Paragraph.setBold.
Instead of (1, 6, true)
I've also tried (parseInt('1'),parseInt('6'),true)
, and (one, six, true)
, ('one', 'six', true)
. What does it want from me?
function motion() {
var body = DocumentApp.getActiveDocument().getBody();
var par1m = body.appendParagraph('Motion—_____ moved and _____ seconded that _____.');
par1m.setBold(1, 6, true);
par1m.setItalic(false);
par1m.setUnderline(false);
par1m.setStrikethrough(false);
par1m.setFontFamily("Times New Roman");
par1m.setFontSize(12);
par1m.setForegroundColor('#000000');
par1m.setAlignment(DocumentApp.HorizontalAlignment.LEFT);```
CodePudding user response:
Paragraph
doesn't have a documented setBold()
attribute. Text
does. Use editAsText()
to get a Text
version:
var par1m = body.appendParagraph('Motion—_____ moved and _____ seconded that _____.').editAsText();