LANG SELRCT

Apps Script Reference  (Create: Create new Spreadsheet | Create new Apps Script

Saturday, January 19, 2019

Googleドキュメントにテキストを追加したい


ドキュメントに hello を入力しておいて



hi と hey を追加する




コード.gs
function addText() {
  var url = "https://docs.google.com/document/d/ID/edit";
  var doc = DocumentApp.openByUrl(url);
  var body = doc.getBody();
  body.appendParagraph("hi" + "\n" + "hey");
}


getBody()しなくても動いた。
DocumentApp.openByUrl(url).appendParagraph("hi" + "\n" + "hey")


参考

appendParagraph(text)
https://developers.google.com/apps-script/reference/document/body#appendParagraph(String)

Latest post

スプレッドシートA列にある複数のテキストをスライドに追加したい(Google Apps Script)

今回Google Apps Scriptでやりたいこと GoogleスプレッドシートA列にある複数の値を取得して Googleスライドに渡して 図形オブジェクトのテキストとして追加したい ① スプレッドシートのA列に値を入れておく ② Code.gsのinsertNewShape...