我正在嘗試將整個檔案從一個復制到另一個。
我只是想將一個 INLINE_DRAWING 從一個谷歌檔案復制到另一個,但我一直收到這個錯誤。如果我取消附加繪圖的嘗試,則沒有錯誤,但是在我完成的檔案中沒有繪圖。您如何正確地將內嵌繪圖從一個檔案復制到另一個檔案?
// fromFile & toFile are objects after calling .getBody()
function copyFileContentsFromTo(fromFile,toFile){
for(var i=0; i<fromFile.getNumChildren();i ){ //run through the elements of the template doc's Body.
var child = fromFile.getChild(i);
switch (fromFile.getChild(i).getType()) { //Deal with the various types of Elements we will encounter and append.
case DocumentApp.ElementType.PARAGRAPH:
// Look for child elements within the paragraph. Inline Drawings are children.
if(child.asParagraph().getNumChildren() !=0 && child.asParagraph().getChild(0).getType() == DocumentApp.ElementType.INLINE_DRAWING) {
console.log("Found an Inline Drawing");
var drawing = child.asParagraph();
toFile.append(drawing.copy()); // This causes the error!
}else{
toFile.appendParagraph(child.copy());
}
break;
case DocumentApp.ElementType.TABLE:
toFile.appendTable(child.copy());
break;
default:
console.log("Whoops. Did not handle this Element Type when Copy Data from Template to Main: " fromFile.getChild(i).getType());
break;
}
}
}
我已經搜索遍了,找不到任何資源,這是最接近的,但仍然在我的螢屏截圖中產生錯誤:Google 腳本 InlineDrawing 類
uj5u.com熱心網友回復:
在您的腳本中,需要進行如下修改。
從:
toFile.append(drawing.copy());
到:
toFile.appendParagraph(drawing.copy());
重要的:
- 在當前階段,當包含內嵌繪圖的段落被復制時,請禁用 V8 運行時。當上面修改的腳本與 V8 運行時一起使用時,會出現類似的錯誤
Exception: Action not allowed。所以請注意這一點。這已經在谷歌問題跟蹤器上報告了。Ref我相信這個錯誤可以在未來的更新中洗掉。
參考:
- appendParagraph(段落)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/384487.html
上一篇:可能回圈的資料驗證
