class SpreadsheetApp method .openById()

SpreadsheetApp is the Apps Script service.

.openById() is the method name you will see after a dot in your code.

What it does

Opens an existing spreadsheet using its Drive file ID.

Why it's used

  • Pull data from another spreadsheet without asking the user to open it.
  • Common in dashboards that roll up numbers from several files.

Common errors

  • Forgetting parentheses on openById. Write SpreadsheetApp.openById(), not SpreadsheetApp.openById or openById by itself.
  • Skipping dots between chained calls. Each step needs a dot, like SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Data').openById().
  • Adding spaces where they do not belong. Write SpreadsheetApp.openById(), not SpreadsheetApp .openById(), SpreadsheetApp.openById (), or SpreadsheetApp . openById().
  • Wrong capitalization. Use SpreadsheetApp and openById, not spreadsheetapp or openbyid.

Explore

Related methods

3 Better Sheets tutorials

Automate Emails

Automate Emails

Set up automated email notifications based on Google Sheets data. Super ...
Automatically Copy Spreadsheet Tab to New File with Values Only, No Formulas

Automatically Copy Spreadsheet Tab to New File with Values Only, No Formulas

Automatically copy a spreadsheet tab to a whole new spreadsheet file, ge...
Automatic Calculations

Automatic Calculations

Create custom scripts to make your spreadsheets more like tools.

Related blog posts

Written guides about SpreadsheetApp.openById().

Browse the blog