Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

selecting all text frames on all visible layers

Explorer ,
Mar 03, 2013 Mar 03, 2013

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

TOPICS
Scripting
2.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Mar 03, 2013 Mar 03, 2013

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

Translate
Adobe
Community Expert ,
Mar 03, 2013 Mar 03, 2013

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 03, 2013 Mar 03, 2013

It works! don't really know how, but it does.

Thanks,

Duane

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 03, 2013 Mar 03, 2013
LATEST

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*/}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines