将文本从一个 google 文档复制到另一个活动的 google 文档

Copying text from one google Doc, to another active google Doc

我在管理文件夹中的主文档(google 文档)中有一段文本,我想将其复制到我正在工作的活动 google 文档中on(如果有帮助,那将是空白的)。

我对 JS 很陌生,一直在尝试使用 getFileById(fileId).makeCopy,但我很挣扎。

任何关于我应该看哪些教程或我如何去做这件事的指示都会很有帮助。

谢谢!

从文档中打开 script.google.com:

Tools -> Script Editor

使用这个函数:

function textCopy() {
  var doc = DocumentApp.openById('ID_OF_DOC_TO_BE_COPIED').getText();
  var body = DocumentApp.getActiveDocument().getBody();
  var text = body.editAsText();
  // Insert text at the beginning of the document.
  text.insertText(0, doc);
}

运行吧。会要求一些权限,一定要允许。

可以在 Class Text 中找到有关文档文本操作的更多信息。