总的来说,我希望人们将一些数据放入Google表格中,并提供一个按钮,该按钮将获取数据并自动填充预制的Google幻灯片。我选择了一种方法来复制主幻灯片,然后用数据替换单个文本模块。我的目标是否有更好的方法?
这是主幻灯片
This is the code i use for the duplication, but it is only able to duplicate the master slide once, because the objectId it creates, is always the same: "copiedSlide_001". I have tried to use a random integer for the objectId, but i dont get it to work. Also, i guess the name has to be predictable to be used in the next step. (importing the data into newly copied slide).
function duplicateSlide() {
var presentationId = "1XLtOv7FHWwv6R2QEZF_LEhF7twXTlY3IbvsVDKxdDtc";
var pageId = "g75e5d89173_0_0"
var requests = [{
"duplicateObject": {
"objectId": pageId,
"objectIds": {
"g75e5d89173_0_0": "copiedSlide_001",
}
}
} ]Slides.Presentations.batchUpdate({'requests': requests}, presentationId);
}
How do i get the duplication process to work in my favor?
I would appreciate any help highly!
copiedSlide_001
.
If my understanding is correct, how about this answer? Please think of this as just one of several possible answers.
Before you run the script, please enable Slides API at Advanced Google services.
function duplicateSlide() {
var presentationId = "1XLtOv7FHWwv6R2QEZF_LEhF7twXTlY3IbvsVDKxdDtc"; // Please set the Slides ID.
var pageId = "g75e5d89173_0_0"; // Please set the page ID of the source slide.
var newIDs = ["copiedSlide_001", "copiedSlide_002", "copiedSlide_003"]; // Please set the unique ID here.
var requests = newIDs.reverse().map(function(id) {
var obj = {};
obj[pageId] = id;
return {duplicateObject: {objectId: pageId, objectIds: obj}};
});
// requests.push({deleteObject: {objectId: pageId}});
Slides.Presentations.batchUpdate({'requests': requests}, presentationId);
}
requests.push({deleteObject: {objectId: pageId}});
,则在复制完成后,将删除第一页(即源幻灯片)。但是我不确定这是否是您想要的结果。因此,我将其作为注释添加到了脚本中。如果我误解了您的问题,而这不是您想要的方向,我深表歉意。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句