- Created the script in Apple Script.
- Created an action in Apple Shortcuts.
Running from Shortcuts, I get File can't be imported.
But If I click on the shortcut and select "Edit" and run it from there, it opens but it isn't correct. I set the page orientation to landscape, but it wants to print in portrait.
If I run it directly from Apple Script, I get the error that it is not allowed to send keystrokes.
The errors don't seem to be consistent.
Here is the script - It worked flawlessly before Sonoma.
-- Script Editor User Guide for Mac - Apple Support
tell application "Numbers"
open ("/Users/silvasp/Downloads/Export.csv") as POSIX file
activate
end tell
tell application "Numbers"
tell document 1
delete (row 1 of table 1 of active sheet)
delete (row 1 of table 1 of active sheet)
delete (row 1 of table 1 of active sheet)
end tell
end tell
tell application "Numbers"
tell document 1
delete (column 1 of table 1 of active sheet)
delete (column 2 of table 1 of active sheet)
delete (columns 7 through 7 of table 1 of active sheet)
end tell
end tell
tell application "Numbers"
tell document 1
set format of (column 3 of table 1 of active sheet) to currency
set format of (column 4 of table 1 of active sheet) to currency
set format of (column 5 of table 1 of active sheet) to currency
end tell
end tell
tell application "Numbers"
tell document 1
set alignment of row 1 of table 1 of active sheet to center
tell application "System Events" to keystroke "b" using {command down}
set background color of row 1 of table 1 of active sheet to {35767, 35767, 35767}
set the width of (column 3 of table 1 of active sheet) to 65
set the width of (column 4 of table 1 of active sheet) to 65
set the width of (column 5 of table 1 of active sheet) to 65
end tell
tell application "System Events" to keystroke "p" using {command down}
delay 1
tell application "System Events" to keystroke "p" using {command down}
end tell
tell application "System Events"
tell application process "Numbers"
set frontmost to true
tell menu bar 1 to tell menu bar item "File" to tell menu 1 to tell menu item 23
click
end tell
tell window "Export"
tell scroll area 2 to tell button 2
-- page orientation: button 1 to portrait; button 2 to landscape
click
end tell
tell button 5
click
end tell
end tell
end tell
end tell