This returns the currently active spreadsheet, or null if there is none.
var currentSheet = SpreadsheetApp.getActive(); var url = currentSheet.getUrl(); Logger.log( url );