Skip to main content
SteveP-Integra
Known Participant
November 30, 2023
Answered

Updating a script tag using applescript (ID 18.6)

  • November 30, 2023
  • 1 reply
  • 435 views

Last year I wrote a script to find the contents of a cell in a table and then change the value in the script label for that cell.

 

This year I've gone back to it and it's failing on the following:

get contents of every cell

 

Here's a portion of the script that loops over the tables on the page:

 

set myFrame to (every text frame whose label is item 1 of myFrames)

 

repeat with x in myFrame

tell table 1 of x

get contents of every cell

set myList to (every cell of column 1 where contents of it is "WOW")

repeat with i from length of myList to 1 by -1

set myCell to item i of myList

if i is less than 10 then

set label of myCell to "[WOWCode" & "0" & i & "]"

else

set label of myCell to "[WOWCode" & i & "]"

end if

end repeat

end tell

end repeat

 

Any idea why it's failing?

This topic has been closed for replies.
Correct answer rob day

@rob day I commented out 'get contents of every cell'

 

I now get the following error:

error "Adobe InDesign 2023 got an error: Can’t get every cell of column 1 of table 1 of text frame id 7050 of spread id 6133 of document id 56 whose contents = \"WOW\"." number -1728 from every cell of column 1 of table 1 of text frame id 7050 of spread id 6133 of document id 56 whose contents = "WOW"


Try changing

tell table 1 of x

to

tell item 1 of x

 

If that doesn’t work wrap the code in a try statement

 

tell application id "com.adobe.indesign"
	try
		set myFrame to (every text frame whose label is item 1 of myFrames)
		repeat with x in myFrame
			tell table 1 of x
				get contents of every cell
				set myList to (every cell of column 1 where contents of it is "WOW")
				repeat with i from length of myList to 1 by -1
					set myCell to item i of myList
					if i is less than 10 then
						set label of myCell to "[WOWCode" & "0" & i & "]"
					else
						set label of myCell to "[WOWCode" & i & "]"
					end if
				end repeat
			end tell
		end repeat
	end try
end tell

1 reply

rob day
Community Expert
Community Expert
November 30, 2023

Hi @SteveP-Integra , Are you getting an error message?

 

get contents of every cell wouldn’t do anything, does the script work if you remove that line?

SteveP-Integra
Known Participant
November 30, 2023

@rob day  thanks for the reply. Yes the error message is:

 

error "Adobe InDesign 2023 got an error: Can’t get contents of every cell of table 1 of text frame id 7050 of spread id 6133 of document id 54." number -1728 from contents of every cell of table 1 of text frame id 7050 of spread id 6133 of document id 54

rob day
Community Expert
Community Expert
November 30, 2023

Does it work if you delete get contents of every cell? The get line isn’t doing anything