1

Using AppleScript to manipulate Numbers to help organize youth wrestling tournaments:

The relevant portion of my script looks like this:

    -- SELECT THE ROWS
    tell document 1
        tell active sheet
            tell table 1
                set WeightClassRows to ¬
                    ((name of first cell of row "3") & ":" & (name of last cell of row EndWeightClass))
                set the selection range to range WeightClassRows
            end tell
        end tell
    end tell

So far, it works. Once I have certain rows selected, I need to copy the information and paste it elsewhere. This works:

    -- COPY THE INFORMATION 

    tell application "System Events"
        keystroke "c" using {command down}
    end tell

    ...

    -- PASTE THE INFORMATION SOMEWHERE ELSE

    tell application "System Events"
        keystroke "v" using {command down, option down, shift down}
    end tell

But I would prefer to use the clipboard to copy the information rather than system events. However, I can't figure it out despite searching and trying a number of things, such as:

    set the clipboard to WeightClassRows   

    set the clipboard to range WeightClassRows

    set the clipboard to content of WeightClassRows

    set the clipboard to content of selection range

But none of these (or similar things) work. Either it returns the cell reference ("B3:J9"), nothing at all, or returns an error saying something like "Can't get content of B3:J9"

Any ideas on how to use the clipboard rather than system events to copy the information once it is selected?

Thank you!

  • I'm not familiar with the term `content` in commonly-used AppleScript terminology, although I don't use _Numbers_, so it may be specific to that. But, most often, `contents` is used to evaluate an AppleScript object. Regarding the clipboard, one of the troubles is that AppleScript uses a different, older API to manipulate the clipboard versus the one used when triggering `cmd-V`. To get some insight, perform a copy with _System Events_, then in _Script Editor_, run the command `return the clipboard info` to see what sort of data gets put on there (also: `return the clipboard as record`). – CJK Nov 23 '19 at 21:09

0 Answers0