Copy link to clipboard
Copied
I want to select all text frames on all visible layers.
the script below will select all text frames even in groups but when a layer with text on it is invisible the script will error.(target layer cannot be modified)
if (app.documents.length > 0 ) {
var doc = app.activeDocument;
var numTextFrames = 0;
for ( i = 0; i < doc.textFrames.length; i++ ) {
textArtRange = doc.textFrames;
textArtRange.selected = true;
}
}
So I made this script to select text frames on only the visible layers but it now misses text that is in a group.
var layerCount = activeDocument.layers.length;
var docSelected = activeDocument.selection;
for (i = 0; i < layerCount; i++)
{
currentLayer = activeDocument.layers;
if (currentLayer.visible == visible )
{
for ( j = 0; j < currentLayer.textFrames.length; j++ ) {
textArtRange = currentLayer.textFrames
textArtRange.selected = true;
}
}
}
can anyone tell me why it does not selected textframes in a group when done this way and is there a way to get all textframes selected on all visible layers?
Thanks,
Duane
Try this:
if (app.documents.length > 0 ) {
var doc = app.activeDocument;
var numTextFrames = 0;
for ( i = 0; i < doc.textFrames.length; i++ ) {
try {
textArtRange = doc.textFrames;
textArtRange.selected = true;
} catch (e) {}
}
}
Have fun
Copy link to clipboard
Copied
Try this:
if (app.documents.length > 0 ) {
var doc = app.activeDocument;
var numTextFrames = 0;
for ( i = 0; i < doc.textFrames.length; i++ ) {
try {
textArtRange = doc.textFrames;
textArtRange.selected = true;
} catch (e) {}
}
}
Have fun
Copy link to clipboard
Copied
It works! don't really know how, but it does.
Thanks,
Duane
Copy link to clipboard
Copied
DuanesSearchForKnowledge wrote:
… don't really know how, but it does …
It's easy:
try { // try to execute the following command
textArtRange = doc.textFrames; // if there are no errors, then continue, otherwise go to the catch line
textArtRange.selected = true; // if there are no errors, then continue, otherwise go to the catch line
} catch (e) {/*otherwise do something else*/}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now