Skip to main content
dublove
Legend
Aug 10, 2025 5:10 PM UTC
Answered

When there is no selection, how can I obtain all paragraphs and table cells in the document?

If no objects are selected, all text Frames in current document will be processed.

I have two targets:
    1. Text paragraphs outside the table.
    2. Cells inside the table.
How can I get them?

 

Like this:

obj.texts[0].appliedParagraphStyle)=parStn;
obj.texts[0].tables.everyItem().cells.everyItem().texts[0].appliedParagraphStyle = bodyParStn;

This is my code above.
It seems that it can only go up to this point: alert(“here”);
There is no response below that.

    var myDocument = app.documents.item(0);
    var myStory = myDocument.stories;
    for (var s = 0; s < myStory.length; s++) {
        alert("here");
      var what = "^.";
        var res = getGrepSearch(what, app.activeDocument);
        for (var f = 0; f <res.length; f++) {
            var obj = app.selection[f];
...
}
}

 

rob day
rob dayCorrect answer
Community Expert
Aug 18, 2025 2:46 PM UTC

Hi Rob Day.
It seems that one scenario has been overlooked.

When no object is selected, how can we indicate that we want to retrieve images outside of the text box?

 


You can get all of the document’s graphics—this is an array not a collection:

 

var g = app.activeDocument.allGraphics
alert("An array of " + g.length + " graphics")

 

20 replies

rob day
Community Expert
Community Expert
Aug 10, 2025 6:31 PM UTC

Text paragraphs outside the table.

Cells inside the table.

 

var p = app.activeDocument.stories.everyItem().paragraphs.everyItem().getElements()
var c = app.activeDocument.stories.everyItem().tables.everyItem().cells.everyItem().getElements()
alert("An array of " + c.length + " cells in this document")
alert("An array of " + p.length + " paragraphs in this document not included in tables")

 

 

 

Translate
dublove
dubloveAuthor
Legend
Aug 11, 2025 3:26 AM UTC

It's better to use variables instead of this method, otherwise it will be too long.
I was thinking about your function yesterday. I now have five scenarios, each with independent code, which is a bit long.

Translate