Оптимизируйте свои подборки Сохраняйте и классифицируйте контент в соответствии со своими настройками.
Именованный диапазон
Range , имеющий имя и идентификатор, позволяющий его позднее получить. Имена не обязательно уникальны; несколько разных диапазонов на одной вкладке могут иметь одно и то же имя, как класс в HTML. Идентификаторы, напротив, уникальны внутри вкладки, как идентификатор в HTML. После добавления Named Range на вкладку его нельзя изменить, а только удалить.
Доступ Named Range можно получить с помощью любого сценария, обращающегося к вкладке. Чтобы избежать непреднамеренных конфликтов между сценариями, рассмотрите возможность добавления к именам диапазонов префиксов с уникальной строкой.
// Create a named range that includes every table in the active tab.constdocumentTab=DocumentApp.getActiveDocument().getActiveTab().asDocumentTab();constrangeBuilder=documentTab.newRange();consttables=documentTab.getBody().getTables();for(leti=0;i < tables.length;i++){rangeBuilder.addElement(tables[i]);}documentTab.addNamedRange('myUniquePrefix-tables',rangeBuilder.build());
Удаляет этот Named Range с вкладки. Этот метод не удаляет содержимое диапазона; это просто удаляет ссылку. Вызов этого метода для Named Range , который уже был удален, не имеет никакого эффекта.
Авторизация
Сценарии, использующие этот метод, требуют авторизации с одной или несколькими из следующих областей :
[[["Прост для понимания","easyToUnderstand","thumb-up"],["Помог мне решить мою проблему","solvedMyProblem","thumb-up"],["Другое","otherUp","thumb-up"]],[["Отсутствует нужная мне информация","missingTheInformationINeed","thumb-down"],["Слишком сложен/слишком много шагов","tooComplicatedTooManySteps","thumb-down"],["Устарел","outOfDate","thumb-down"],["Проблема с переводом текста","translationIssue","thumb-down"],["Проблемы образцов/кода","samplesCodeIssue","thumb-down"],["Другое","otherDown","thumb-down"]],["Последнее обновление: 2025-07-24 UTC."],[[["\u003cp\u003eA \u003ccode\u003eNamedRange\u003c/code\u003e is a named area within a Google Doc tab, retrievable using its name or unique ID, similar to HTML elements with classes and IDs respectively.\u003c/p\u003e\n"],["\u003cp\u003eWhile multiple ranges can share the same name, IDs are unique within a tab, and once a \u003ccode\u003eNamedRange\u003c/code\u003e is added, it can only be removed, not modified.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eNamedRange\u003c/code\u003e provides methods like \u003ccode\u003egetId()\u003c/code\u003e, \u003ccode\u003egetName()\u003c/code\u003e, \u003ccode\u003egetRange()\u003c/code\u003e, and \u003ccode\u003eremove()\u003c/code\u003e for managing and accessing the named range and its associated elements.\u003c/p\u003e\n"],["\u003cp\u003eScripts can access \u003ccode\u003eNamedRange\u003c/code\u003e within a tab, and using unique prefixes for range names helps avoid conflicts between different scripts.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eNamedRange\u003c/code\u003e methods might require specific authorization scopes for accessing and manipulating document content.\u003c/p\u003e\n"]]],[],null,["NamedRange\n\nA [Range](/apps-script/reference/document/range) that has a name and ID to allow later retrieval. Names are not\nnecessarily unique; several different ranges in the same tab may share the same name, much like a\nclass in HTML. By contrast, IDs are unique within the tab, like an ID in HTML. Once a `Named``Range` has been added to a tab, it cannot be modified, only removed.\n\nA `Named``Range` can be accessed by any script that accesses the tab. To avoid unintended\nconflicts between scripts, consider prefixing range names with a unique string.\n\n```javascript\n// Create a named range that includes every table in the active tab.\nconst documentTab =\n DocumentApp.getActiveDocument().getActiveTab().asDocumentTab();\nconst rangeBuilder = documentTab.newRange();\nconst tables = documentTab.getBody().getTables();\nfor (let i = 0; i \u003c tables.length; i++) {\n rangeBuilder.addElement(tables[i]);\n}\ndocumentTab.addNamedRange('myUniquePrefix-tables', rangeBuilder.build());\n``` \n\nMethods\n\n| Method | Return type | Brief description |\n|---------------------------|------------------------------------------------|-----------------------------------------------------------------|\n| [getId()](#getId()) | `String` | Gets the ID of this `Named``Range`. |\n| [getName()](#getName()) | `String` | Gets the name of this `Named``Range`. |\n| [getRange()](#getRange()) | [Range](/apps-script/reference/document/range) | Gets the range of elements associated with this `Named``Range`. |\n| [remove()](#remove()) | `void` | Removes this `Named``Range` from the tab. |\n\nDetailed documentation \n\n`get``Id()` \nGets the ID of this `Named``Range`. The ID is unique within the tab.\n\nReturn\n\n\n`String` --- The range's ID, which is unique within the tab.\n\n*** ** * ** ***\n\n`get``Name()` \nGets the name of this `Named``Range`. The name is not necessarily unique.\n\nReturn\n\n\n`String` --- The range's name, which is not necessarily unique.\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/documents.currentonly`\n- `https://www.googleapis.com/auth/documents`\n\n*** ** * ** ***\n\n`get``Range()` \nGets the range of elements associated with this `Named``Range`.\n\nReturn\n\n\n[Range](/apps-script/reference/document/range) --- The range of elements associated with the name and ID.\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/documents.currentonly`\n- `https://www.googleapis.com/auth/documents`\n\n*** ** * ** ***\n\n`remove()` \nRemoves this `Named``Range` from the tab. This method doesn't delete the contents of the\nrange; it merely the removes the reference. Calling this method on a `Named``Range` that\nhas already been removed has no effect.\n\nAuthorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/documents.currentonly`\n- `https://www.googleapis.com/auth/documents`"]]