property month_names : {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}
tell application "Numbers"
activate
if not (exists document 1) then
display dialog "There is no document open." buttons {"Cancel"} default button 1
end if
repeat
display dialog "Enter the number of items to track and choose the orientation of the month names:" default answer "6" buttons {"Cancel", "Left Column", "Top Row"} default button 1
copy the result to {button returned:month_orientation, text returned:item_count}
try
set the item_count to item_count as integer
if the item_count is greater than 0 then exit repeat
on error
beep
end try
end repeat
tell document 1
tell sheet 1
if the month_orientation is "Top Row" then
set this_table to make new table with properties {name:"MONTHS", column count:13, row count:(item_count + 1)}
tell table "MONTHS"
-- set any global cell properties
set the height of every row to 24
set the vertical alignment of every row to center
set the alignment of every row to center
tell row 1
-- set specific properties for the title row
set the vertical alignment to center
set the alignment to center
-- insert labels
repeat with i from 2 to 13
set value of cell i to item (i - 1) of the month_names
end repeat
end tell
tell column 1
-- set specific properties for the title column
set the vertical alignment to center
set the alignment to center
-- insert labels
repeat with i from 2 to item_count + 1
set value of cell i to "Item " & (i - 1 as string)
end repeat
end tell
end tell
else if the month_orientation is "Left Column" then
set this_table to make new table with properties {name:"MONTHS", column count:(item_count + 1), row count:13}
tell table "MONTHS"
-- set any global cell properties
set the height of every row to 24
set the vertical alignment of every row to center
set the alignment of every row to center
tell column 1
-- set specific properties for the title column
set the vertical alignment to center
set the alignment to center
-- insert labels
repeat with i from 2 to 13
set value of cell i to item (i - 1) of the month_names
end repeat
end tell
tell row 1
-- set specific properties for the title row
set the vertical alignment to center
set the alignment to center
-- insert labels
repeat with i from 2 to item_count + 1
set value of cell i to "Item " & (i - 1 as string)
end repeat
end tell
end tell
end if
end tell
end tell
end tell