0
votes

I am receiving the following error that have started out of the blue. I do not know how to resolve of fix them. These are for Import Range functionality and have been working fine until now...

Error Spreadsheet X:

TypeError: Cannot call method "getRange" of null. (line 3, file "Code")

Script:

var values = SpreadsheetApp.openById('1ka0MPaC1xXcu4EAbmSjc9c7BJyNDwOpggBkix2qMBxY').
getSheetByName('Overtime Activities (Do not edit)').getRange('i3:m1000').getValues();
SpreadsheetApp.getActive().getSheetByName('Form responses 1').
getRange(1,8,values.length,values[0].length).setValues(values);
function timeDriven(e) {
if( e !== undefined )
errorHandling_(monitor_,true);
}

Error Spreadsheet Y:

TypeError: Cannot call method "getRange" of null. (line 6, file "Code")

Script:

var values = SpreadsheetApp.openById('1MJ7D7vOWWPgJBO5MZtZHyPw6Iw0kNlZ8Y5OIwSdzBUg').
getSheetByName('Form responses 1').getRange('a:F').getValues();
SpreadsheetApp.getActive().getSheetByName('Overtime Activities (Do not edit)').
getRange(3,1,values.length,values[0].length).setValues(values);
function timeDriven(e) {
if( e !== undefined )
errorHandling_(monitor_,true);
}

Please help! :)

1
You don't give enough details : could you point which line are line 3 and line 6 ? (even if I can guess it from what you show but guessing is not enough ;-) how is this function called ? by a trigger ? manually ? have you checked the sheet names ? This message comes from a sheet not being defined but as it is one can't tell why it is not. - Serge insas
First error originates from OpenbuID. I have checked and the key is correct. - Imran Ali
Second error from alternate document originates from getRange(3,1 values... - Imran Ali
are you sure about sheets names as well ? check it using Logger.log(SpreadsheetApp.openById('1ka0MPaC1xXcu4EAbmSjc9c7BJyNDwOpggBkix2qMBxY').getSheetByName('Overtime Activities (Do not edit)').getName()) - Serge insas
Yes you were right. I renamed the sheet and managed to have an extra space in there that messed everything up. Thank you. - Imran Ali

1 Answers

0
votes

Extra spacing when renaming sheet threw everything out. Thank you Serge for continuing to point this out! Issue fixed.