0

How do I unhide columns in Numbers using AppleScript? I created a custom shortcut so that +U unhides all columns, so I have tried this so far:

tell application "Numbers"
    open POSIX file "/path/to/file"
    tell document "file"
        set active sheet to sheet "sheet"
        tell table "table" of sheet "sheet"
            set selection range to range "A1"
            tell application "System Events" to keystroke "U" using command down
        end tell
    end tell
end tell

I get no error message, but the columns are still hidden.

I am using the latest version of MacOS, AppleScript, and Numbers.

  • By default, ⌘U is already assigned to Underline under the Format > Font menu. Also when using keystroke with System Events and a modifier key use the lower case of the letter, e.g.: tell application "System Events" to keystroke "u" using command down That said, if you assigned ⌘U to the Unhide All Columns command on the Table menu and not changed the shortcut for the Underline command under the Format > Font menu, you may still have an issue. – user3439894 Mar 6 at 12:32
  • @user3439894 Thanks! I didn't notice the conflict because it worked fine when I unhid the columns manually using the shortcut. – cherryblossom Mar 6 at 20:50
0

I figured it out. As user3439894 said, there was a conflict between the shortcuts for underlining and unhiding columns. I changed it to +U.

I needed to activate the window before shortcuts could be used on it.

tell application "Numbers"
    activate
    open POSIX file "/path/to/file"
    tell document "file"
        set active sheet to sheet "sheet"
        tell table "table" of sheet "sheet"
            set selection range to range "A1"
            tell application "System Events" to keystroke "u" using command down
        end tell
    end tell
end tell
  • You should also use a lower case "u"! – user3439894 Mar 6 at 21:00
  • @user3439894 Thanks. I had a lowercase “u” on my script but I forgot to do that when I posted this answer. – cherryblossom Mar 7 at 6:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .