Stay organized with collections Save and categorize content based on your preferences.
TabA tab within a Google Docs document.
// Get all of the first-level tabs (tabs that are not nested within a parent // tab) in the document. // TODO(developer): Replace the ID with your own. const tabs = DocumentApp.openById('123abc').getTabs(); // Get a specific tab based on the tab ID. // TODO(developer): Replace the IDs with your own. const tab = DocumentApp.openById('123abc').getTab('123abc');Detailed documentation
getChildTabs()
Retrieves the child tabs nested within this tab.
ReturnTab[]
— The child tabs nested within this tab.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/documents.currentonly
https://www.googleapis.com/auth/documents
getId()
Retrieves the ID of the tab.
ReturnString
— The ID of the tab.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/documents.currentonly
https://www.googleapis.com/auth/documents
getIndex()
Retrieves the 0-based index of the tab within the parent.
ReturnInteger
— The index of the tab within the parent.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/documents.currentonly
https://www.googleapis.com/auth/documents
getTitle()
Retrieves the title of the tab.
ReturnString
— The title of the tab.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/documents.currentonly
https://www.googleapis.com/auth/documents
getType()
Retrieves the type of tab.
Use this method to determine the content type of this Tab
before casting to the more specific type using asDocumentTab()
.
const tab = DocumentApp.getActiveDocument().getActiveTab(); // Use getType() to determine the tab's type before casting. if (tab.getType() === DocumentApp.TabType.DOCUMENT_TAB) { // It's a document tab, write some text to it. tab.asDocumentTab().setText('Hello World!'); } else { // There are currently no types other than DOCUMENT_TAB. }Return
TabType
— The tab's type.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/documents.currentonly
https://www.googleapis.com/auth/documents
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-12-02 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-12-02 UTC."],[[["A tab is a structural element within a Google Docs document, allowing for organization and navigation within the document's content."],["You can retrieve all first-level tabs or a specific tab using its ID with the `DocumentApp` class."],["The `Tab` class provides methods for accessing tab properties like title, type, index, and child tabs, as well as retrieving the tab contents as a `DocumentTab`."],["Most `Tab` methods require authorization with scopes such as `https://www.googleapis.com/auth/documents.currentonly` or `https://www.googleapis.com/auth/documents`."],["You can use the `getType()` method to determine the tab type before casting to a specific tab type like `DocumentTab` for further interaction."]]],["This documentation outlines how to interact with tabs in Google Docs via scripting. Key actions include retrieving tabs, either all first-level tabs or a specific one by ID. You can then get a tab's `DocumentTab`, child tabs, ID, index, title, and type. The `getType()` method is crucial for determining the content before using `asDocumentTab()`. All these methods need authorization scopes like `documents.currentonly` or `documents`.\n"]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4