GoogleスライドをApps Scriptで操作する際に、slideIdの取得が必要になったので試してみました。
I tried to get the slide Id via Google Apps Script on Google Slides.
Code.gs
function getCurrentSlideId() {
var presentation = SlidesApp.getActivePresentation();
var selection = presentation.getSelection();
var pageElement = selection.getCurrentPage();
var slide = pageElement.asSlide();
var slideId = slide.getObjectId();
Logger.log(slideId);
}
Tips
Geminiに質問して得た回答をコンパクトにしたのが、上記の Code.gs です。
The Code.gs above is a compact version of the answer I got from Gemini.
Get current slide ID in Google Slides using Apps Script.
Reference
Class SlidesApp > Methods > getActivePresentation()
Class Presentation > Methods > getSelection()
Class Selection > Methods > getCurrentPage()
Class Page > Methods > asSlide()
Class Page > Methods > getObjectId()