Reply To: Script

#115616
Jeremy Howard
Participant

Here, I added some checks, this version checks that the selected item(s) is a text frame, will alert you if it finds an invalid file path within the selected frames and will fit placed images to the frame proportionally…

Enjoy!

//Begin Script//////////////////////////////////////////////////////
var mySelection = app.selection;
for(thisItem = 0; thisItem < mySelection.length; thisItem++){
var currentFrame = mySelection[thisItem];
if(currentFrame instanceof TextFrame){
var frameContents = currentFrame.paragraphs[0].contents;
var myImage = File(frameContents);
try{
currentFrame.place (myImage, false);
}catch(e){
alert(“Invalid file path!\r\rThe file \”” + frameContents + “\” could not be found. \rPlease check the file path and try again.” );
break;
}
currentFrame.fit(FitOptions.PROPORTIONALLY);
}
}
//End Script////////////////////////////////////////////////////////

This article was last modified on March 28, 2019

Comments (0)

Loading comments...