Alter the “Story” number in an Illustrator document

Hi all - posting here separately from another post of mine to simplify my query - hopefully someone can help.

I have the below script which works effectively so long as I use a specific Illustrator template as the target document - BUT if I choose an entirely different document that has all the same elements (essentially a duplicate) the “Story” number changes from “4” to another number and the script fails. Is there a way to alter this “Story” number in the duplicate Illustrator documents to “4” so the script can operate effectively regardless of the target document?
Addendum (if it matters, the contents of the clipboard are copied from 5 Excel cells)

set theClipboard to the clipboard as text

– Split each cell into its own line

set AppleScript’s text item delimiters to tab

set theCells to text items of theClipboard

set AppleScript’s text item delimiters to return

set theModifiedText to theCells as text

– Add two line breaks before the last cell

set theLines to paragraphs of theModifiedText

set theLastLineIndex to count of theLines

set item (theLastLineIndex - 1) of theLines to item (theLastLineIndex - 1) of theLines & return

set theModifiedText to theLines as text

set the clipboard to theModifiedText

tell application “Adobe Illustrator”

activate

tell document 1

select of {text from character 1 to character 66 of story 4 of document 1 of application “Adobe Illustrator”}

set contents of text range of story of selection to the clipboard

end tell

end tell

end

Hi. In other Adobe apps, I find it’s usually best to name the objects and then refer to them by name.

Hi. Unless the items were added in the same order across documents, there would be no consistency with the story number. If you know the target contains certain text, you could use that to name them or to determine the story number.

tell application "Adobe Illustrator"'s document 1
set (get text frame 1 whose contents begins with "123")'s name to "isTarget"
tell text frame "istarget" to set contents to "123" & return & "456"
end tell

Thanks all for your input. I renamed the items in Illustrator so I could refer to them by name in the script rather than the dynamic “story”.