activate application "Numbers"
tell application "System Events" to tell (first process whose frontmost is true)
tell menu bar 1 to tell menu bar item 10 to tell menu 1 to set menuItems to name of menu items
end tell
set lesDocuments to {}
repeat with aDoc in reverse of menuItems
if contents of aDoc is missing value then exit repeat
set end of lesDocuments to aDoc as text
end repeat
repeat with aDoc in lesDocuments
activate application "Numbers"
tell application "System Events" to tell (first process whose frontmost is true) to tell menu bar 1 to ¬
tell menu bar item 10 to tell menu 1 to click menu item (aDoc as text)
# here document aDoc is at front, do your duty
end repeat
It's certainly easy to edit it for Illustrator if there is no instruction to do the job.