Skip to main content
This topic has been closed for replies.
Correct answer alexi66941425
  1. ( function() 
  2.  
  3.     var myFile = File.openDialog 
  4.     ( 
  5.         "Load a file", // Message at top of the window 
  6.         
  7.         function(file) // File filter function 
  8.         { 
  9.             if( file.name.match(/(\.jpg$)|(\.psd$)|(\.tif$)|(\.pdf$)/i) ) 
  10.             { return true
  11.         } , 
  12.             
  13.         false // Multi select 
  14.     ); 
  15.  
  16.     if( myFile == null
  17.     { 
  18.         alert("User canceled. No File loaded."); 
  19.         return 
  20.     }; 
  21.     else 
  22.     { 
  23.         alert( "Selected File Name:"+"|r"+myFile.name ) 
  24.     }; 
  25.  
  26.  
  27.     if(app.selection.length == 0){ return }; 
  28.     var sel = app.selection; 
  29.     
  30.     for(var n=0;n<sel.length;n++) 
  31.     { 
  32.         if( sel.constructor.name == "Rectangle"
  33.         { 
  34.             sel.place( myFile ); 
  35.         } 
  36.     } 
  37.  
  38.  
  39. }() )

1 reply

alexi66941425AuthorCorrect answer
Inspiring
February 14, 2019
  1. ( function() 
  2.  
  3.     var myFile = File.openDialog 
  4.     ( 
  5.         "Load a file", // Message at top of the window 
  6.         
  7.         function(file) // File filter function 
  8.         { 
  9.             if( file.name.match(/(\.jpg$)|(\.psd$)|(\.tif$)|(\.pdf$)/i) ) 
  10.             { return true
  11.         } , 
  12.             
  13.         false // Multi select 
  14.     ); 
  15.  
  16.     if( myFile == null
  17.     { 
  18.         alert("User canceled. No File loaded."); 
  19.         return 
  20.     }; 
  21.     else 
  22.     { 
  23.         alert( "Selected File Name:"+"|r"+myFile.name ) 
  24.     }; 
  25.  
  26.  
  27.     if(app.selection.length == 0){ return }; 
  28.     var sel = app.selection; 
  29.     
  30.     for(var n=0;n<sel.length;n++) 
  31.     { 
  32.         if( sel.constructor.name == "Rectangle"
  33.         { 
  34.             sel.place( myFile ); 
  35.         } 
  36.     } 
  37.  
  38.  
  39. }() )