I read on here how to use the script =sheetName() to display the sheet name, but is there another script I can use to display the workbook title?

I use daily sheets and the title for the sheets are the date. When I print them, I want it to display the date (located in the title).
(I know I can show the title in the print settings but that's a lot of steps if I'm mass printing)

2 Answers 2


Use the getName() method from the Class Spreadsheet.

We don't need a script to display the Spreadsheet title when printing.

  1. Click on File > Print
  2. On the right panel, expand the Headers & footers section
  3. Check the Workbook title to add it to the default field or click on Edit Custom Fields to add it to the field that prefer.
  • Thanks for the help but I already said that I knew that option. I'm trying to find a way that it auto inserts the title in a cell so I don't have to go in the print options for each and every sheet.
    – Justin
    Jan 16, 2018 at 17:43
  • @Justin: You edited your question to said that 5 minutes ago :) Jan 16, 2018 at 17:51
  • Yes, I was just making it more clear for future readers.
    – Justin
    Jan 17, 2018 at 12:10

Put this into the script editor, then save and close the script editor:

function GetSheetName() {
return SpreadsheetApp.getActiveSpreadsheet().getName();

Then do =GetSheetName() in a cell and you will have the workbook title.

If you want the title of a sheet/tab within the workbook, use this instead:

function GetSheetName() {
return SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getName();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.