TypeError: Cannot call method “getActiveSheet” of

2019-08-20 09:25发布

TypeError: Cannot call method "getActiveSheet" of null

SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getRange("D2").setValue(99)

Please look into the screenshot All i want to set the value into the sheet with given range.

Code.gs

sheat01

Here is the code

function myF() {
var app = SpreadsheetApp;
var g_as = app.getActiveSpreadsheet();
var as = g_as.getActiveSheet();
as.getRange("D2").setValue(99);

}

1条回答
甜甜的少女心
2楼-- · 2019-08-20 09:36

I did this and it works. The Logger comes back with the word Range. I had no expectation that it would come back with anything.

function myF()
{
   SpreadsheetApp.getActive().getActiveSheet().getRange('D2').setValue(99);
}

It changes O19 to 99 every time.

Whenever I start getting weird stuff going on I shut down the browser and come back up and that generally does the trick.

查看更多
登录 后发表回答