2017-08-21 6 views
0

テキストを選択し、選択したテキストを大文字に変更してから同じテキストをコピーするAdobe InDesignスクリプトを作成しようとしています。 私は立ち往生しています。Adob​​e Indesignスクリプトを大文字に変更し、テキストをクリップボードにコピー

#target "InDesign" 
 

 
var myDoc = app.activeDocument; 
 

 

 
if(app.documents.length != 0){ 
 
    if(app.selection.length == 1){ 
 
     try{   
 
      //var text = app.selection[0]. 
 
      var frame1 = page.textFrames[0]; 
 
      //var frame2 = page.textFrames[1]; 
 

 
      frame1.texts.everyItem().select(); 
 
      //frame1. 
 
      app.copy(); 
 
     } 
 
     catch(e){ 
 
      alert ("Please select text", "Selection"); 
 
     } 
 
    } 
 
else{ 
 
    alert ("Please select text", "Selection"); 
 
    } 
 
} 
 
else{ 
 
\t alert("Something wrong"); 
 
}

+0

を誤り 'キャッチ(のホールドを取得します。 e){ alert( "例外が発生しました:" + e、 "例外");は何が起きているのかをトラブルシューティングするのに役立ちます。私は '' var frame1 = page.textFrames [0]; ' –

答えて

3
var myDoc = app.activeDocument; 

if(app.documents.length != 0){ 
    if(app.selection.length == 1){ 
     try{   
      //var text = app.selection[0]. 
      //var frame1 = app.selection[0].textBoxes[0].contents; 
      var frame1 = app.documents[0].pages[0].textFrames[0]; 
      frame1.contents = frame1.contents.toUpperCase(); 
     } 
     catch(e){ 
      alert ("Exception : " + e, "Exception"); 
     } 
    } 
else{ 
    alert ("Please select text", "Selection"); 
    } 
} 
else{ 
    alert("Something wrong"); 
} 

ここでは、選択したオブジェクトを使用している:clipbaordする

var myDoc = app.activeDocument; 

if(app.documents.length != 0){ 
    if(app.selection.length == 1){ 
     try{   
      var frame1 = app.selection[0]; 
      frame1.contents = frame1.contents.toUpperCase(); 
     } 
     catch(e){ 
      alert ("Exception : " + e, "Exception"); 
     } 
    } 
else{ 
    alert ("Please select text", "Selection"); 
    } 
} 
else{ 
    alert("Something wrong"); 
} 

コピー:

var myDoc = app.activeDocument; 

if(app.documents.length != 0){ 
    if(app.selection.length == 1){ 
     try{   
      var selectedStuff = app.selection[0]; 

      //upperCase the selection right away. 
      //If a textFrame is selected, everything in the TextFrame gets upperCased. 
      //If only part of the text is selected, then only part of the text is upperCased. 
      selectedStuff.contents = selectedStuff.contents.toUpperCase(); 
      /////////////// 

      //app.copy(copies the selected Item, not only Text) so find out what's is selected before you shove it onto the clipboard. 
      if(selectedStuff instanceof TextFrame){ 
       //The selected item was a textFrame, a TextFrame can't be pasted into Notepad, so lets select all the text in that frame instead. 
       app.selection = selectedStuff.texts; 
       } 
      //Now copy the selection. At this point, only TEXT should be selected, so pasting should always work. 
      app.copy(); 
     } 
     catch(e){ 
      alert ("Exception : " + e, "Exception"); 
     } 
    } 
else{ 
    alert ("Please select text", "Selection"); 
    } 
} 
else{ 
    alert("Something wrong"); 
} 
+0

'で' 'ページは未定義です。' 'いいですか、内容をクリップボードにコピーするコードを追加してもよろしいですか? – Kamotho

+1

'app.copy()'は、選択した** item **をクリップボードに 'コピ​​ー 'します。 ** item **がテキストフレームの場合、textFrameはクリップボードにコピーされます(この**アイテムタイプ**はIndesignのみが知っているので、inDesignに貼り付けられます)。選択した**項目**がtextFrame内のテキストである場合、テキストはクリップボードにコピーされます。テキストの文字列は単なる文字列なので、** item type **は実行されるすべての単一のプログラムで知られているため、選択/コピーされた項目をほとんど何にでも貼り付けることができます。私はすぐにいくつかのコードを追加します。 –

+0

@KamosKamotho、クリップボード機能の追加 –

関連する問題