Apps Script公式リファレンス: Apps Script Reference |障害・課題追跡: IssueTracker |Google Workspace: Status Dashboard - Summary

2024年4月15日月曜日

Google Apps Scriptでスライド内のページIDを取得したい(.getObjectId)


GoogleスライドのURL末尾にあるslide=id.に続くidを取得したくて書いたコードです。


サンプルのURL→ https://docs.google.com/presentation/d/SLIDE_ID/edit#slide=id.g2cc2c94e9c6_0_0





Code.gs
function getPageIds() {
const url = 'https://docs.google.com/presentation/d/SLIDE_ID/edit#slide=id.p';
const slide = SlidesApp.openByUrl(url);
const pages = slide.getSlides();
const pageIds = [];
for(let i = 0; i < pages.length; i++) {
const pageId = pages[i].getObjectId();
pageIds.push(pageId);
}
Logger.log(pageIds)
}



実行結果


サンプルのスライドには5枚存在するため、5つのidがログに出ています。
1枚目のidは p になるらしい。



Reference

Class Page > getObjectId() 

Latest post

Google Apps Scriptの障害時はIssueTrackerを見てみる - Incidents for Apps Script are reported on Issue Tracker

IssueTracker > Apps Script issues https://issuetracker.google.com/savedsearches/566234 Google Apps Scriptの障害時は IssueTracker に課題が上がっていることが...