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

Updating a script tag using applescript (ID 18.6)

Explorer ,
Nov 30, 2023 Nov 30, 2023

Copy link to clipboard

Copied

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?

TOPICS
Scripting

Views

140

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 , Nov 30, 2023 Nov 30, 2023

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
				
...

Votes

Translate

Translate
Community Expert ,
Nov 30, 2023 Nov 30, 2023

Copy link to clipboard

Copied

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?

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
Explorer ,
Nov 30, 2023 Nov 30, 2023

Copy link to clipboard

Copied

@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

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 ,
Nov 30, 2023 Nov 30, 2023

Copy link to clipboard

Copied

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

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
Explorer ,
Nov 30, 2023 Nov 30, 2023

Copy link to clipboard

Copied

@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"

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 ,
Nov 30, 2023 Nov 30, 2023

Copy link to clipboard

Copied

LATEST

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

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