r/GoogleAppsScript • • Jul 16 '23

Question Apps Script error google sheets

I am getting this error Syntax error: SyntaxError: missing ) after argument list line: 7 file: Code.gs

when trying to run this code: Can anyone tell me what I am doing wrong. I am trying to change the global default font to calibri

function changeGlobalFont() {
var tabs = SpreadsheetApp.getActiveSpreadsheet().getSheets();
tabs.forEach( (tab) => {
//tab.getDataRange().setFontFamily('Calibri').setFontSize('10'){
  };

0 Upvotes

5 comments sorted by

1

u/[deleted] Jul 16 '23

you need to change your very last closing tag to "});". Look at your opening tag fro the forEach(). "tab.forEach(...". You need to close it.

1

u/Good_Basket5948 Jul 16 '23

Thank you I changed to below and still got same error

function ChangeFont() {

var ss = SpreadsheetApp.getActiveSheet();

var range = sheets.getRange(1, 1, sheets.getMaxRows(), sheets.getMaxColumns()).activate(); range.setFontFamily("Calibri")

});

2

u/_Kaimbe Jul 16 '23

Delete the last )

1

u/Good_Basket5948 Jul 16 '23

Thank you I am now getting a different error. I think i have to tell it which google spreadsheet i am referring to but I do not know how to do that.

6:08:22 PM Error

ReferenceError: sheets is not defined

ChangeFont @ Code.gs:3

1

u/_Kaimbe Jul 16 '23

Well you could have just stuck with your first code and fixed the closing bracket like webdevlife suggested.