質問するログイン新規登録

質問編集履歴

3

追加した

2021/04/09 04:50

投稿

takahashi-one
takahashi-one

スコア120

title CHANGED
File without changes
body CHANGED
@@ -36,4 +36,6 @@
36
36
  ```
37
37
 
38
38
  if文をtry-catchで囲ったところ、there is no documentというエラーメッセージがでました。
39
- ボタンクリックでコールするexportFileToPNG24の場合activeDocumentがない状態になってしまう。
39
+ ボタンクリックでコールするexportFileToPNG24の場合activeDocumentがない状態になってしまう。
40
+
41
+ 対象Documentをアクティブにする方法はどのようにすればいいでしょうか?

2

追加した

2021/04/09 04:50

投稿

takahashi-one
takahashi-one

スコア120

title CHANGED
File without changes
body CHANGED
@@ -36,4 +36,4 @@
36
36
  ```
37
37
 
38
38
  if文をtry-catchで囲ったところ、there is no documentというエラーメッセージがでました。
39
- どのように変更ればいでか?
39
+ ボタンクリックでコールるexportFileToPNG24の場合activeDocumentがな状態になって

1

追加した

2021/04/09 03:43

投稿

takahashi-one
takahashi-one

スコア120

title CHANGED
File without changes
body CHANGED
@@ -9,6 +9,7 @@
9
9
  var btnExport = palette.add("button", undefined, "Export");
10
10
 
11
11
  function exportFileToPNG24(dest) {
12
+ try {
12
13
  if (app.documents.length > 0) {
13
14
  var exportOptions = new ExportOptionsPNG24();
14
15
  exportOptions.antiAliasing = false;
@@ -18,9 +19,12 @@
18
19
  var type = ExportType.PNG24;
19
20
  var fileSpec = new File(dest);
20
21
 
21
- app.activeDocument.exportFile(fileSpec, type, exportOptions);
22
+ app.activeDocument.exportFile(fileSpec, type, exportOptions);←ここでエラーとなってる模様。
22
23
  }
24
+ }catch(e) {
25
+ alert( e.message, "スクリプト警告", true);
23
26
  }
27
+ }
24
28
 
25
29
  palette.show();
26
30
 
@@ -29,4 +33,7 @@
29
33
  }
30
34
 
31
35
  /*exportFileToPNG24('C:/test/test.png');*/ ←この位置だとちゃんとpngが保存される。
32
- ```
36
+ ```
37
+
38
+ if文をtry-catchで囲ったところ、there is no documentというエラーメッセージがでました。
39
+ どのように変更すればいいでしょうか?