Problems copying a row and pasting it in the following row

Hi all,
In a Numbers table I have 400 rows with data separated each one by a blank row
row 2 has data
row 3 is blank
row 4 has data
row 5 is blank ... and so on.
I have prepared a small script to copy row 2 into row 3, row 4 into row 5,... as follows:
set dName to "Conta"
set sName to "Movis"
set tName to "Pruebas"
set row_ini to 2
tell application "Numbers" to tell document dName to tell sheet sName to tell table tName
set selection range to row row_ini
repeat
if value of first cell of selection range = 0 then
exit repeat
else
tell application "System Events"
keystroke "c" using {command down}
keystroke return
keystroke "v" using {command down}
end tell
tell first cell of the selection range to set rowNum to address of its row
set selection range to row (rowNum + 1)
end if
end repeat
end tell
The idea is:
1 select the initial row (in this case row 2)
2 check if the value of first cell of the row is cero, then exit the repeat loop
3 else
4 copy the entire row, move down a row and paste.
5 move to the next row
6 repeat
The first time I run the script it worked until the row 124 and stopped. I tried again changing the inicial row and it worked only for 7 rows. The third time it erased all the cells with data. I've tried closing both the table and the script but the problems persists: in this case it stops after replacing 5 rows.
Where am I wrong?
Thank you in advance
Ratz

KOENIG Yvan wrote:
There is not such a book.
There is just on short chapter dedicated to iWork in :
Hanaan Rosenthal & Hamish Sanderson, Learn AppleScript: The Comprehensive
Guide to Scripting and Automation on Mac OS X, Third Edition, Apress (2010);
ISBN 978-1-4302-2361-0
You may find useful infos in my idisk :
<http://public.me.com/koenigyvan>
Scan the contents of the folder :
For_iWork:iWork '09:for_Numbers09.
I guess the problem is for using the tell application block without telling the process Numbers.
No, I had to change a lot of things.
the name of the document was wrong (at least on my machine on which I always use the name extension.
set selection range … was wrong.
Yvan KOENIG (VALLAURIS, France) dimanche 20 février 2011 23:02:35
Thank you.
Visiting your idisk I realise how much work I must do to become a decent scripter!
The book you mention looks interesting. I'm going to include it in my bookcase (and read it, of course).
Ratz

Similar Messages

Maybe you are looking for