Search code examples
urlgoogle-apps-scriptgoogle-sheetscell

Google Spreadsheets: Show Document URL in cell. Possible?


Simple Question: I would like to get the URL of the active Document (google spreadsheet) in a specific cell.

So if I enter =GetUrl() in A1 of https://docs.google.com/spreadsheet/ccc?key=XXXXXXXXXXXXXXXXXX&usp=drive_web#gid=16

should give me the result https://docs.google.com/spreadsheet/ccc?key=XXXXXXXXXXXXXXXXXX&usp=drive_web#gid=16 in the cell A1


Solution

  • A function like this might be useful:

    function GetUrl() {
      var ss = SpreadsheetApp.getActiveSpreadsheet();
      return ss.getUrl();
    }
    

    enter image description here

    Check: Class Spreadsheet - getUrl()