I'm trying to create a function in google sheets to get the workbook name from url link.
function getFileName(id) {
var file = SpreadsheetApp.openByUrl(id)
var fileName = file.getName();
return fileName;
}
I receive message
"Error You do not have permission to call openByUrl"
I tried
var file = DriveApp.getFileById(id);
I receive the same sort of message
"No item with the given ID could be found, or you do not have permission to access it. "