Adobe InDesign 16.4 - Paragraph Count Errors

Did something recently change with either Script Editor or InDesign 16.4? I am not getting errors in long existing scripts when trying to capture the count of paragraphs in a selected text frame. Here is my code;

tell application “Adobe InDesign 2021”

--Set to 5.0 scripting object model
set version of script preferences to 5.0

-- Variable Definition Section--
set myBox to parent of selection -- active selected text frame being styled

--sets the default number of paragraphs in the selected text frame
set firstParaCount to count of paragraphs of myBox

end tell

The error I’m getting is - “Adobe InDesign 2021 got an error: every paragraph of page id 8055 of spread id 8048 of document “2022 SNO Master Style Sheet.indd” doesn’t understand the “count” message.”

I’ve used this same coding philosophy for 20 years now and have never gotten these errors. Thank you in advanced for any assistance you can offer.

Hi, you probably know this already, but I tested this on InDesign 2021 and Catalina, and it works as expected.


selection is a list

you have to use

set myBox to item 1 of selection

parent of selection is a page

Thank you kerflooey.

I am on Big Sur, but have built and successfully tested these scripts since the update. But something has changed in the last few weeks that i’m unsure of. Did the scripting language supported by InDesign change in 2021?

The error you are getting suggests that what is selected is a text frame, the parent of which is the page.

Making sure the selection is text, counts paragraphs as I would expect.

The small tweak of including “item 1 of selection” has fixed the errors. Thank you all for helping me hit my deadline! Happy Holidays!