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

Get content of all text frames in selection

Participant ,
Apr 12, 2017 Apr 12, 2017

Copy link to clipboard

Copied

Hi

I nedd to get content of all text frames in selection

Thanks

TOPICS
Scripting

Views

1.4K

Translate

Translate

Report

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 , Apr 12, 2017 Apr 12, 2017

Try this:

s = '';

for (var i = 0; i < app.selection.length; i++) {

  if (app.selection instanceof TextFrame) {

    s += app.selection.parentStory.contents + '\r';

  }

}

P.

Votes

Translate

Translate
Enthusiast ,
Apr 12, 2017 Apr 12, 2017

Copy link to clipboard

Copied

Try this,

for(i=0; i<app.activeDocument.pages.length; i++)

{

    for(var j=0;j<app.activeDocument.pages.textFrames.length;j++)

    {

        alert(app.activeDocument.pages.textFrames.contents)

    }

}

Votes

Translate

Translate

Report

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
Participant ,
Apr 12, 2017 Apr 12, 2017

Copy link to clipboard

Copied

No all text frames (stories) in document but in selection

for example i have 3 frames but i select 2 frames (see picture). I need content from two selected frames

Thanks

selection.PNG

Votes

Translate

Translate

Report

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
Guide ,
Apr 12, 2017 Apr 12, 2017

Copy link to clipboard

Copied

You may try with script what I gave..

Votes

Translate

Translate

Report

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
LEGEND ,
Apr 12, 2017 Apr 12, 2017

Copy link to clipboard

Copied

Hi,

    var mySelection = app.selection;

    for ( var s = 0; s < mySelection.length; s++ ) mySelection.texts[0];

(^/) 

Votes

Translate

Translate

Report

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
Guide ,
Apr 12, 2017 Apr 12, 2017

Copy link to clipboard

Copied

Like Sajeev code.. if you need only to view the selected text frame content..

for(i=0; i<app.activeDocument.textFrames.length-1; i++)

{

    alert(app.selection.contents);

  

}

Votes

Translate

Translate

Report

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 ,
Apr 12, 2017 Apr 12, 2017

Copy link to clipboard

Copied

Try this:

s = '';

for (var i = 0; i < app.selection.length; i++) {

  if (app.selection instanceof TextFrame) {

    s += app.selection.parentStory.contents + '\r';

  }

}

P.

Votes

Translate

Translate

Report

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
Participant ,
Apr 12, 2017 Apr 12, 2017

Copy link to clipboard

Copied

Thanks

But this solution don't work when i group frames

Votes

Translate

Translate

Report

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
Participant ,
Apr 12, 2017 Apr 12, 2017

Copy link to clipboard

Copied

I change your code and it works.

You have huge knowlege pkahrel

sel = app.selection;

s = '';

for (var i = 0; i < app.selection.length; i++) {

  if (sel instanceof TextFrame) {

    s += sel.parentStory.contents + '\r';

  }

  if (sel instanceof Group) {

    for (var j = 0; j < sel.textFrames.length; j++ )

    s += sel.textFrames.contents + '\r';

  }

}

alert(s)

Votes

Translate

Translate

Report

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
Guide ,
Apr 12, 2017 Apr 12, 2017

Copy link to clipboard

Copied

LATEST

Please mark Peter code to correct answer..

Votes

Translate

Translate

Report

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