What is a bound script in Google Sheets?
A bound script, also called a container-bound script, lives inside a specific spreadsheet file. You open it from Extensions > Apps Script and it travels with that workbook. getActiveSpreadsheet() works naturally because the script and sheet share one container. Most spreadsheet automations beginners build are bound scripts.
When to use it
Use a bound script when automation belongs to one workbook: custom menus, onEdit on that file, form responses tab, or a web app backed by that sheet data.
When to skip it
Choose a standalone script when one codebase must manage many spreadsheets by ID, or when you publish a workspace add-on not tied to a single file.
How it works
-
1
Open Extensions > Apps Script from the target spreadsheet to create or edit the bound project.
-
2
The script project ID is linked to this file in Drive, not floating alone in My Drive unless copied.
-
3
Simple triggers onEdit and onOpen run in the context of this spreadsheet.
-
4
Deploy web apps from the bound project; they usually read the parent sheet via getActiveSpreadsheet or openById on the parent.
-
5
Copying the spreadsheet copies the script container, but verify triggers and authorizations after duplicate.
-
6
clasp clone works on bound projects for local development with git.
Examples in Google Sheets
Custom Operations menu
onOpen in the bound script adds a menu to this workbook only, calling functions that format the active tab.
Invoice generator
Bound script reads line items from the same file, builds a PDF in Drive, and emails the customer.
Internal admin tool
A bound web app deployment serves managers a lookup UI over rows in the parent spreadsheet.
Better Sheets resources
Common mistakes
-
Expecting a bound script to see another file's active sheet without openById and permissions.
-
Duplicating the sheet for testing and forgetting triggers still point at old functions or accounts.
-
Mixing up two open files and editing the wrong bound script in another tab.
-
Moving the spreadsheet to a shared drive without checking who can edit the script project.
-
Assuming bound means private; editors of the sheet can usually open the script.
Frequently asked questions
- What is the difference between bound and standalone scripts?
- Bound scripts are attached to one spreadsheet or other Google file. Standalone scripts live as their own project in Drive and open files by ID.
- How do I find my bound script?
- Open the spreadsheet, then Extensions > Apps Script. That editor is the bound container.
- Does the script copy when I copy the sheet?
- Generally yes, the copy includes a script project. Triggers and authorizations may need setup again.
- Can a bound script access other spreadsheets?
- Yes with openById if the running account has permission to those files.
- Can I detach a bound script?
- You can copy code into a standalone project, but Google does not offer a simple detach button. Recreate as standalone if needed.
- Who can edit a bound script?
- Typically users with edit access to the parent spreadsheet, unless admin policies restrict Apps Script editing.
- Is a bound script an add-on?
- No. Add-ons are published separately. Bound scripts are private to the file unless you publish wider.
- Does bound script work with Google Forms linked to the sheet?
- Yes. Form submit triggers in the bound project run when responses arrive in the linked spreadsheet.
Related Tutorials
Watch how bound script works
From Sheet to Script And Back Again - Learn to Code In Google Sheets Part 3
Now Do It Every Damn Day - Learn to Code in Google Sheets Part 5
Embed a Number in a Website from a Google Sheet
Password Protecting Data In a Google Sheet
Curate Google Sheets Easily - Automatic Bookmarklet Maker
Self Destructing Google Sheet
Related blog posts
Guides that explain bound script in more depth.
What's Better Than Google Sheets?
Nothing is better than Google Sheets. You just need to learn more about the unlimited power of Google Sheets. Functions, Formulas, Apps Script and more.
Read post →Explore Coding in Google Sheets
Did you know you can actually code in Google Sheets?
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 →Related terms
Script Editor
The Script Editor is the Apps Script workspace inside your spreadsheet where you write JavaScript that talks to Sheets, Gmail, and other Google services. You open it from Extensions > Apps Script. Every function you save can be run manually, bound to a trigger, or linked from a custom menu.
Read guide →Apps Script triggers
Triggers tell Apps Script when to run a function: on edit, on open, on a schedule, or when a form is submitted. Simple triggers use reserved names like onEdit. Installable triggers are created in the Apps Script Triggers page and can do more, including running as a specific user or on a timer.
Read guide →onOpen trigger
The onOpen trigger runs an Apps Script function automatically when someone opens the spreadsheet. It is the standard way to add custom menus, show instructions, or refresh lightweight cache without asking the user to run a macro first. Name the function onOpen or bind it as an installable open trigger.
Read guide →Google Sheets automation
Automation means work happens without repeating the same clicks every day: imports update, emails send, rows move, and dashboards refresh. In Sheets, automation usually stacks built-in features, Apps Script, and sometimes the Sheets API or add-ons. Start with the lightest tool that still solves the job.
Read guide →Done reading about bound script?
Membership unlocks 600+ tutorials, unlimited generators, and every template. Practical lessons. Zero fluff.
Need this once
Jump to a free tool or a single tutorial for this topic.
Learning Sheets for real
Unlock the full library, generators, and templates with membership.