Set the height of row I to 21

I have the following AppleScript:

tell application "Pages"
 		set Rij to2
		set index of window DocumentNaam to 1
		tell (front document)
			set the Tabel to (the first table whose name is "XXXX")
			tell Tabel
				repeat with i from 1 to 3
					make new row at (after row Rij)
					set Rij to Rij + 1
					set the height of row Rij to 21
				end repeat
			end tell
		end tell

I have two questions:

 1. If I search on the internet, I should use 'add row' in stead of 'make new row'. But add row doesn't work. Can anyone tell me why?

 2. If, the repeat loop is done the first time, he sets the row height to 21, as asked. But when I=2, he set the height to 21 BUT the height of the former row to 20. When I=3; he sets the new row to 21, the former last to 20 and the second last to 19.  What am I doing wrong?

Thank in advance!

Hi Amelie.

Before version 5.0, Pages was far more scriptable than it is now. It had ‘add chart’ and ‘add table’ commands, but as far as I know, it’s never had an ‘add row’ command. Numbers still has ‘add row above’ and ‘add row below’ commands.

Unhelpfully, your script fragment works exactly as expected on my machine. :confused: You could, though, make use of the specifier returned by the ‘make’ command to ensure that it’s the new row whose height is being set.

tell application "Pages"
	set Rij to 2
	--set index of window DocumentNaam to 1
	tell (front document)
		set the Tabel to (the first table whose name is "XXXX")
		tell Tabel
			repeat with i from 1 to 3
				set height of (make new row at (after row Rij)) to 21
				set Rij to Rij + 1
			end repeat
		end tell
	end tell
end tell

Or perhaps something like this:

tell application "Pages"
	set Rij to 2
	--set index of window DocumentNaam to 1
	tell (front document)
		set the Tabel to (the first table whose name is "XXXX")
		tell Tabel
			set thisRow to row Rij
			repeat 3 times
				set thisRow to (make new row at after thisRow)
				set height of thisRow to 21
			end repeat
			set Rij to address of thisRow
		end tell
	end tell
end tell

Hi,

I have found what is causing my problem.
In pages there is the option of a table: “match rows to cell contents” (excuse me, if it is not correct translated, but I’ve a dutch version of pages). When this option is turned on, the script behaves correctly. But, when it is turned off, the script behaves as told in my former post.

Does somebody know what is causing the difference?

My understanding that you didn’t identify the real problem.
I tested Pages 8.1 which is the last version usable on my machine with an open document embedding a table named “XYZ”.
Below is the test script:

tell application "Pages"
	activate
	tell (document 1)
		iWork items --> {}
		tables --> {}
		set Tabel to (first iWork item whose name is "XYZ")
		--> error number -1719 from iWork item 1 of document 1 whose name = "XYZ"
	end tell
end tell

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mardi 13 octobre 2020 16:17:21