Page Summary
-
A bound script is attached to a specific Google Sheets, Docs, Slides, or Forms file, called its container.
-
Bound scripts behave similarly to standalone scripts but do not appear in Google Drive and cannot be detached from their container.
-
Bound scripts have special privileges, including the ability to refer to their parent file without its ID and interact with the parent file's user interface to add custom menus, dialogs, and sidebars.
-
Bound scripts can be created from within the Google Docs, Sheets, Slides, or Forms file they will be bound to.
-
Bound scripts can use simple and installable triggers, and in Google Sheets, they can be used to create custom functions.
A script is bound to a Google Sheets, Google Docs, Google Slides, or Google Forms file if it was created from that document rather than as a standalone script. The file that a bound script is attached to is called a "container." Bound scripts generally behave like standalone scripts except that they don't appear in Google Drive, they can't be detached from the file they are bound to, and they gain a few special privileges over the parent file.
Scripts can also be bound to Google Sites, but these scripts are almost always deployed as web apps. Scripts bound to Sheets, Docs, Slides, or Forms can also become web apps, although this is uncommon.
Bound scripts are effectively unpublished Google Workspace add-ons that function only for the file they are bound to.
Create a bound script
You can create bound scripts in Docs, Sheets, Slides, and Forms.
Docs, Sheets, or Slides
To create a bound script in Docs, Sheets, or Slides, open a document in Docs, a spreadsheet in Sheets, or a presentation in Slides and click Extensions > Apps Script. To reopen the script in the future, do the same thing or open the script from the Apps Script dashboard.
Forms
To create a bound script in Forms, open a form and click More