Pilihan pengguna dalam presentasi aktif.
const selection = SlidesApp.getActivePresentation().getSelection(); const currentPage = selection.getCurrentPage(); const selectionType = selection.getSelectionType();
Metode
| Metode | Jenis hasil yang ditampilkan | Deskripsi singkat | 
|---|---|---|
| get | Page | Menampilkan Pageataunullyang saat ini aktif jika tidak ada halaman yang aktif. | 
| get | Page | Menampilkan koleksi PageinstancePageyang
dipilih ataunulljika tidak ada instancePageyang dipilih. | 
| get | Page | Menampilkan Pagekumpulan instancePagedi flimstrip yang
dipilih ataunulljika pilihannya bukan dari jenisSelection. | 
| get | Selection | Menampilkan Selection. | 
| get | Table | Menampilkan koleksi TableinstanceTableyang dipilih
ataunulljika tidak ada instanceTableyang dipilih. | 
| get | Text | Menampilkan Textyang dipilih ataunulljika pilihannya bukan dari jenisSelection. | 
Dokumentasi mendetail
get
Menampilkan Page atau null yang saat ini aktif jika tidak ada halaman yang aktif.
const selection = SlidesApp.getActivePresentation().getSelection(); const currentPage = selection.getCurrentPage(); if (currentPage != null) { Logger.log(`Selected current active page ID: ${currentPage.getObjectId()}`); }
Pulang pergi
Otorisasi
Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:
- 
https://www.googleapis.com/auth/presentations.currentonly
- 
https://www.googleapis.com/auth/presentations
get
Menampilkan koleksi Page instance Page yang
dipilih atau null jika tidak ada instance Page yang dipilih.
const selection = SlidesApp.getActivePresentation().getSelection(); const selectionType = selection.getSelectionType(); if (selectionType === SlidesApp.SelectionType.PAGE_ELEMENT) { const currentPage = selection.getCurrentPage(); const pageElements = selection.getPageElementRange().getPageElements(); Logger.log(`Number of page elements selected: ${pageElements.length}`); }
Pulang pergi
Otorisasi
Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:
- 
https://www.googleapis.com/auth/presentations.currentonly
- 
https://www.googleapis.com/auth/presentations
get
Menampilkan Page kumpulan instance Page di flimstrip yang
dipilih atau null jika pilihannya bukan dari jenis Selection.
const selection = SlidesApp.getActivePresentation().getSelection(); const selectionType = selection.getSelectionType(); if (selectionType === SlidesApp.SelectionType.PAGE) { const pageRange = selection.getPageRange(); Logger.log( `Number of pages in the flimstrip selected: ${ pageRange.getPages().length}`, ); }
Pulang pergi
Otorisasi
Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:
- 
https://www.googleapis.com/auth/presentations.currentonly
- 
https://www.googleapis.com/auth/presentations
get
Menampilkan Selection.
const selection = SlidesApp.getActivePresentation().getSelection(); const selectionType = selection.getSelectionType(); if (selectionType === SlidesApp.SelectionType.CURRENT_PAGE) { const currentPage = selection.getCurrentPage(); Logger.log(`Selected current active page ID: ${currentPage.getObjectId()}`); }
Pulang pergi
Otorisasi
Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:
- 
https://www.googleapis.com/auth/presentations.currentonly
- 
https://www.googleapis.com/auth/presentations
get
Menampilkan koleksi Table instance Table yang dipilih
atau null jika tidak ada instance Table yang dipilih.
const selection = SlidesApp.getActivePresentation().getSelection(); const selectionType = selection.getSelectionType(); if (selectionType === SlidesApp.SelectionType.TABLE_CELL) { const currentPage = selection.getCurrentPage(); const tableCells = selection.getTableCellRange().getTableCells(); const table = tableCells[0].getParentTable(); Logger.log(`Number of table cells selected: ${tableCells.length}`); }
Pulang pergi
Otorisasi
Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:
- 
https://www.googleapis.com/auth/presentations.currentonly
- 
https://www.googleapis.com/auth/presentations
get
Menampilkan Text yang dipilih atau null jika pilihannya bukan dari jenis
Selection.
Text mewakili dua skenario:
1. Rentang teks yang dipilih. Misalnya, jika bentuk memiliki teks "Halo", dan "Dia" dipilih,
rentang yang ditampilkan memiliki Text = 0, dan Text =
2.
2. Posisi kursor. Misalnya, jika bentuk memiliki teks "Halo", dan kursor berada setelah "H",
("H|ello"), rentang yang ditampilkan memiliki Text = 1 dan Text = 1.
const selection = SlidesApp.getActivePresentation().getSelection(); const selectionType = selection.getSelectionType(); if (selectionType === SlidesApp.SelectionType.TEXT) { const currentPage = selection.getCurrentPage(); const pageElement = selection.getPageElementRange().getPageElements()[0]; const textRange = selection.getTextRange(); Logger.log(`Text selected: ${textRange.asString()}`); }
Pulang pergi
Otorisasi
Skrip yang menggunakan metode ini memerlukan otorisasi dengan satu atau beberapa cakupan berikut:
- 
https://www.googleapis.com/auth/presentations.currentonly
- 
https://www.googleapis.com/auth/presentations