A [[Google Apps Script]] created from a Google Workspace product like Sheets or Forms is said to be [container-bound](https://developers.google.com/apps-script/guides/bound). Bound scripts have access to special methods for interacting with their container (i.e., the Sheet or Form from which they were created). To create a container-bound script, open Apps Script from the Extensions menu in Sheets, Docs or Slides or click *More > Script editor* in Forms. You may need to add Apps Script as an extension first (*New > More > Connect more apps*). # special methods Bound scripts can call a few methods that [[standalone]] scripts cannot: - [`getActiveSpreadsheet()`](https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet-app#getActiveSpreadsheet\(\)), [`getActiveDocument()`](https://developers.google.com/apps-script/reference/document/document-app#getActiveDocument\(\)), [`getActivePresentation()`](https://developers.google.com/apps-script/reference/slides/slides-app#getactivepresentation), and [`getActiveForm()`](https://developers.google.com/apps-script/reference/forms/form-app#getActiveForm\(\)) allow bound scripts to refer to their parent file without referring to the file's ID. - [`getUi`](https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet-app#getUi\(\)) lets bound scripts access the user interface for their parent file to add [custom menus, dialogs, and sidebars](https://developers.google.com/apps-script/guides/bound#custom_menus_dialogs_and_sidebars). - In Google Sheets, [`getActiveSheet()`](https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet-app#getActiveSheet\(\)), [`getActiveRange()`](https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet-app#getActiveRange\(\)), and [`getActiveCell()`](https://developers.google.com/apps-script/reference/spreadsheet/sheet#getActiveCell\(\)) let the script determine the user's current sheet, selected range of cells, or selected individual cell. [`setActiveSheet(sheet)`](https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet-app#setActiveSheet\(Sheet\)) and [`setActiveRange(range)`](https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet-app#setActiveRange\(Range\)) let the script change those selections. - In Google Docs, [`getActiveTab()`](https://developers.google.com/apps-script/reference/document/document#getActiveTab\(\)), [`getCursor()`](https://developers.google.com/apps-script/reference/document/document#getCursor\(\)), and [`getSelection()`](https://developers.google.com/apps-script/reference/document/document#getSelection\(\)) let the script determine the user's current tab, position of the user's cursor, or selected text. [`setActiveTab(tabId)`](https://developers.google.com/apps-script/reference/document/document#setActiveTab\(String\)), [`setCursor(position)`](https://developers.google.com/apps-script/reference/document/document#setCursor\(Position\)) and [`setSelection(range)`](https://developers.google.com/apps-script/reference/document/document#setSelection\(Range\)) let the script change those selections. For more information, see the [guide to extending Google Sheets](https://developers.google.com/apps-script/guides/sheets) or the [guide to extending Google Docs](https://developers.google.com/apps-script/guides/docs). ## index [[add custom menu]] [[assign script to button]] [[read project from CDN]] [[read in data]] [[format dates]] [[get cell value]] [[truncate and load]]