Class Selection Stay organized with collections Save and categorize content based on your preferences.
Page Summary
The Selection object represents the current selection in an active presentation.
You can get the currently active page, selected page elements, selected pages in the filmstrip, selected table cells, or selected text range using methods like
getCurrentPage(),getPageElementRange(),getPageRange(),getTableCellRange(), andgetTextRange().The type of the current selection can be determined using the
getSelectionType()method.
The user's selection in the active presentation.
constselection=SlidesApp.getActivePresentation().getSelection();constcurrentPage=selection.getCurrentPage();constselectionType=selection.getSelectionType();
Methods
| Method | Return type | Brief description |
|---|---|---|
get | Page|null | Returns the currently activePage ornull if there is no active page. |
get | Page | Returns thePage collection ofPage instances that areselected ornull if there are noPage instances selected. |
get | Page | Returns thePage a collection ofPage instances in the flimstrip that areselected ornull if the selection is not of typeSelection. |
get | Selection | Returns theSelection. |
get | Table | Returns theTable collection ofTable instances that are selectedornull if there are noTable instances selected. |
get | Text | Returns theText that is selected ornull if the selection is not of typeSelection. |
Detailed documentation
getCurrentPage()
Returns the currently activePage ornull if there is no active page.
constselection=SlidesApp.getActivePresentation().getSelection();constcurrentPage=selection.getCurrentPage();if(currentPage!=null){Logger.log(`Selected current active page ID:${currentPage.getObjectId()}`);}
Return
Page|null
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/presentations.currentonlyhttps://www.googleapis.com/auth/presentations
getPageElementRange()
Returns thePage collection ofPage instances that areselected ornull if there are noPage instances selected.
constselection=SlidesApp.getActivePresentation().getSelection();constselectionType=selection.getSelectionType();if(selectionType===SlidesApp.SelectionType.PAGE_ELEMENT){constcurrentPage=selection.getCurrentPage();constpageElements=selection.getPageElementRange().getPageElements();Logger.log(`Number of page elements selected:${pageElements.length}`);}
Return
Page
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/presentations.currentonlyhttps://www.googleapis.com/auth/presentations
getPageRange()
Returns thePage a collection ofPage instances in the flimstrip that areselected ornull if the selection is not of typeSelection.
constselection=SlidesApp.getActivePresentation().getSelection();constselectionType=selection.getSelectionType();if(selectionType===SlidesApp.SelectionType.PAGE){constpageRange=selection.getPageRange();Logger.log(`Number of pages in the flimstrip selected:${pageRange.getPages().length}`,);}
Return
Page
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/presentations.currentonlyhttps://www.googleapis.com/auth/presentations
getSelectionType()
Returns theSelection.
constselection=SlidesApp.getActivePresentation().getSelection();constselectionType=selection.getSelectionType();if(selectionType===SlidesApp.SelectionType.CURRENT_PAGE){constcurrentPage=selection.getCurrentPage();Logger.log(`Selected current active page ID:${currentPage.getObjectId()}`);}
Return
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/presentations.currentonlyhttps://www.googleapis.com/auth/presentations
getTableCellRange()
Returns theTable collection ofTable instances that are selectedornull if there are noTable instances selected.
constselection=SlidesApp.getActivePresentation().getSelection();constselectionType=selection.getSelectionType();if(selectionType===SlidesApp.SelectionType.TABLE_CELL){constcurrentPage=selection.getCurrentPage();consttableCells=selection.getTableCellRange().getTableCells();consttable=tableCells[0].getParentTable();Logger.log(`Number of table cells selected:${tableCells.length}`);}
Return
Table
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/presentations.currentonlyhttps://www.googleapis.com/auth/presentations
getTextRange()
Returns theText that is selected ornull if the selection is not of typeSelection.
TheText represents two scenarios:
1. Range of text selected. For example if a shape has text "Hello", and "He" is selected,the returned range hasText = 0, andText =2.
2. Cursor position. For example if a shape has text "Hello", and cursor is after "H",("H|ello"), the returned range hasText = 1 andText = 1.
constselection=SlidesApp.getActivePresentation().getSelection();constselectionType=selection.getSelectionType();if(selectionType===SlidesApp.SelectionType.TEXT){constcurrentPage=selection.getCurrentPage();constpageElement=selection.getPageElementRange().getPageElements()[0];consttextRange=selection.getTextRange();Logger.log(`Text selected:${textRange.asString()}`);}
Return
Text
Authorization
Scripts that use this method require authorization with one or more of the followingscopes:
https://www.googleapis.com/auth/presentations.currentonlyhttps://www.googleapis.com/auth/presentations
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-11 UTC.