回答編集履歴

2

新たな手法のバージョンを追記しました。

2023/10/06 21:41

投稿

YellowGreen
YellowGreen

スコア861

test CHANGED
@@ -1,3 +1,25 @@
1
+ (10/7 追記)
2
+ 特定のフォルダの中にあるドキュメントファイルを全て処理対象にします。
3
+
4
+ ```JavaScript
5
+ //IDで指定したフォルダの中のドキュメントを対象にする
6
+ function getImageFromDocument() {
7
+ const folderId = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
8
+ const files = DriveApp.getFolderById(folderId).getFiles();
9
+ while (files.hasNext()) {
10
+ const file = files.next();
11
+ if (file.getMimeType().includes('google-apps.document')) {
12
+ const images = DocumentApp.openById(file.getId())
13
+ .getBody().getImages();
14
+ for (const image of images) {
15
+ image.setHeight(300);
16
+ image.setWidth(300);
17
+ }
18
+ }
19
+ }
20
+ }
21
+ ```
22
+ (追記前)
1
23
  複数のドキュメントIDを冒頭に配列として定義しておきます。
2
24
 
3
25
  ```JavaScript

1

誤字の修正

2023/10/06 08:11

投稿

YellowGreen
YellowGreen

スコア861

test CHANGED
@@ -1,4 +1,4 @@
1
- 複数のドキュメントIDを冒頭に配列として定義しておます。
1
+ 複数のドキュメントIDを冒頭に配列として定義しておます。
2
2
 
3
3
  ```JavaScript
4
4
  function getImageFromDocument() {