質問編集履歴

3

追加した

2021/04/09 04:50

投稿

takahashi-one
takahashi-one

スコア119

test CHANGED
File without changes
test CHANGED
@@ -75,3 +75,7 @@
75
75
  if文をtry-catchで囲ったところ、there is no documentというエラーメッセージがでました。
76
76
 
77
77
  ボタンクリックでコールするexportFileToPNG24の場合activeDocumentがない状態になってしまう。
78
+
79
+
80
+
81
+ 対象Documentをアクティブにする方法はどのようにすればいいでしょうか?

2

追加した

2021/04/09 04:50

投稿

takahashi-one
takahashi-one

スコア119

test CHANGED
File without changes
test CHANGED
@@ -74,4 +74,4 @@
74
74
 
75
75
  if文をtry-catchで囲ったところ、there is no documentというエラーメッセージがでました。
76
76
 
77
- よう変更すればいいでか?
77
+ ボタンクリックでコールするexportFileToPNG24場合activeDocumentがない状態なって

1

追加した

2021/04/09 03:43

投稿

takahashi-one
takahashi-one

スコア119

test CHANGED
File without changes
test CHANGED
@@ -20,6 +20,8 @@
20
20
 
21
21
  function exportFileToPNG24(dest) {
22
22
 
23
+ try {
24
+
23
25
  if (app.documents.length > 0) {
24
26
 
25
27
  var exportOptions = new ExportOptionsPNG24();
@@ -38,9 +40,15 @@
38
40
 
39
41
 
40
42
 
41
- app.activeDocument.exportFile(fileSpec, type, exportOptions);
43
+ app.activeDocument.exportFile(fileSpec, type, exportOptions);←ここでエラーとなってる模様。
42
44
 
43
45
  }
46
+
47
+ }catch(e) {
48
+
49
+ alert( e.message, "スクリプト警告", true);
50
+
51
+ }
44
52
 
45
53
  }
46
54
 
@@ -61,3 +69,9 @@
61
69
  /*exportFileToPNG24('C:/test/test.png');*/ ←この位置だとちゃんとpngが保存される。
62
70
 
63
71
  ```
72
+
73
+
74
+
75
+ if文をtry-catchで囲ったところ、there is no documentというエラーメッセージがでました。
76
+
77
+ どのように変更すればいいでしょうか?