Best/Easiest Way to Import Spreadsheet Cells Directly to Variable Values?

I have a clunky setup right now where I have a "Prompt For User Input" window pop up in one of my macros and then I have to copy and paste a bunch of values from a spreadsheet into the corresponding list of over 20 Variable Values in the KM popup. Making it even clunkier, I'm not able to simply COMMAND-TAB back and forth between the Numbers spreadsheet and the KM editor because it loses the focus of the KM Popup window every time when switching back and forth...

Is there any way to just import a column of spreadsheet cells directly into KM as variables or at the very least a way to refocus the popup window of KM when I switch back and forth between the Editor and the Numbers app?

If it helps at all, the contents of the Spreadsheet cells are just simple text things like "Video Title" "Video Description" "Video Tags" etc. that are then used as corresponding variables in KM in a series of macros each day for automating the uploading of the videos to various sites so the variables need to be updated on a regular basis with each new video upload that has it's own new matching spreadsheet with all of the specific info/variables for that specific video already filled out

One way I can think of is to use python to:

  1. read (and write) excel files, and then
  2. set KM variables.

Numbers has decent AppleScript support. You should be able to use it to get the values in several cells.

I have a KM macro that reads a file and uses regex to get the important data from it. I mention this because the file happens to a CSV file that I've downloaded from a database. It essentially lets me search a locally cached copy of the database with KM.

It might make sense for you to automatically create a copy of the spreadsheet using something like https://stackoverflow.com/questions/10557360/convert-xlsx-to-csv-in-linux-with-command-line/10580741#10580741 and then just parse the CSV with KM.

Fwiw, that link talks about using gnumeric (available via homebrew) and the ssconvert utility built into gnumeric to automate the xlsx to csv conversion on a mac.

New to KM, so please take my comment for whatever it's worth:

I'm surprised there isn't a scriptable way to access/edit a named set of KM macros. If there were then couldn't a spreadsheet be used to take "variable" data and integrate it with the relevant KM macro script? In operating the massaged, variable-to-literal spreadsheet-output KM script would be cut from the sheet cell, pasted into the KM source pane and executed. Or, as someone else pointed out, the actual spreadsheet cell could be accessed by KM.

There is using AppleScript with the KM Editor.

Sounds like you want to build a KM Macro using data from Excel. Is that correct?

IMO, it is much better for a KM Macro and/or script to access data in Excel.
This way you only need one macro.

Or maybe I've completely missed your point?

JMichaelTX, thanks for taking the time to comment. I'll search harder for an example how to access/edit a named set of KM macros using AppleScript. I agree, it would be preferable to just access data from the spreadsheet. Again, thanks for the tip.

Hey Todd,

Welcome to the forum!   :smile:

You should post an actual example of what you're trying to do to the forum.

It sounds like you're making your task overly complicated, but I can't really tell from your description.

If you haven't read this it's worth a couple of minutes of your time.

Tip: How Do I Get The Best Answer in the Shortest Time?

This too:

How to Post Your Macro to the Forum

-Chris