Opens an existing spreadsheet using its Drive file ID.
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
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.
2 Snippets using this methods
Explore
Related methods
-
.openByUrl()
Opens an existing spreadsheet from its full URL.
-
.create()
Creates a new blank spreadsheet file in Drive.
-
.getActiveSpreadsheet()
Returns the spreadsheet the user currently has open.
-
.showModalDialog()
Opens a modal dialog that blocks interaction with the sheet.
-
.activate()
Makes a sheet or range the active selection.
More Apps Script
3 Better Sheets tutorials
Automate Emails
Automatically Copy Spreadsheet Tab to New File with Values Only, No Formulas
Related blog posts
Written guides about SpreadsheetApp.openById().
How to reference a different Google Spreadsheet in Apps Script?
Transferring Data Between Cells in Different Spreadsheets
Read post →How to Use Google Sheets as a Website Database
Did you know you can use Google Apps Script to turn a Google Sheet into a free, auto-syncing database for your website? This guide shows you exactly how to set it up. You’ll prepare your spreadsheet, write a few lines of code and publish your site. Don’t worry if you’re not a developer, we’ll walk you through it. Why Use Google Sheets as a Database? For small projects, Google Sheets offers many advantages over traditional databases: * Free hosting and storage * Easy to edit data without...
Read post →Automatic Weekly Backup of Google Sheets
How can we create backups of Google sheets every week or every day or every month?
Read post →