1

I want to write a bash script for a mac which takes a text file containing a table of numbers (can be .csv), converts the numbers to a chart, saves the chart (any file format that I can display on my web page), and exits. It must do this unattended. No user interaction.

I know bash, perl, and a little AppleScript, and I can learn VBA or whatever else. I am about to plunk down money for the new Excel 2011 for Mac. I think I want Excel rather than Numbers'09, but I am not at all sure, and I think VBA or AppleScript will allow me to automate most of the work.

Is AppleScript + Excel a good choice? If so, then I'm home free. Applescript programs can be launched from bash via osascript command.

But maybe VBA is better? But how can I launch a Excel VBA script from bash on a mac?

Summary of questions: (1) AppleScript or VBA or something else? (2) Excel or Numbers? (3) How to launch Excel VBA script from bash?

Thanks in advance, Ken

6 Answers 6

2

Don't forget to try OpenOffice (and derivatives). It's been a while since I last worked with it, but they have a macro language and some VBA support (don't know how good it is now, I'm sure it's progressed) - so it could likely generate your graphs for you.

Alternatively, this sounds like something Gnuplot could very easily do. See this article where they start with the raw data in a text file, and create a PNG file for use in a web page: http://www.ibm.com/developerworks/aix/library/au-gnuplot/index.html

Just thought you should know about other options than Excel and Numbers...

Sign up to request clarification or add additional context in comments.

1 Comment

Nice. I am sympathetic to GNU/Linux based solutions. Thanks for the suggestion!
1

You should definitively consider using gnuplot (free), which can easily create graphics and even HTML5 canvas elements from different input file formats via the command line.

Comments

0

iWork 09 does support Applescript. Pages is pretty good with its support. Numbers far less so. I think most expect more expansive Applescript support with the new version as Numbers only has partial support. So for what the original question asks you really need to use Excel.

If you are going to script I'd look seriously at Python or Ruby combined with Appscript rather than Applescript or VBA. Applescript is a bear of a language to write in and using one of the other languages gives you all the libraries of that language. That allows quite a bit more powerful code to be written.

If you are just writing for Office and don't need much other functionality then I'd probably stick with VBA.

1 Comment

AppScript, eh? Never heard of it. Thank you for the suggestion. I'm interested!
0

You might like to take a look at Google Chart Tools.

It is exceptionally useful for including charts and graphs within web pages.

You just create a URL containing the data as a src for an image, then tada, it appears.

Have a play.

For instance, a few parameters:

chd=t:10,20,30
chco=FF0000|00FF00|0000FF
chs=320x240
cht=p3
chdl=Red|Green|Blue

Makes a URL: https://chart.googleapis.com/chart?chd=t:10,20,30&chco=FF0000|00FF00|0000FF&chs=320x240&cht=p3&chdl=Red|Green|Blue

Which forms a chart:

Example Pie Chart

Comments

0

I would recommend using Numbers and AppleScript if you are on OS X—these are well integrated. Also, you could use Automator to make your life even simpler.

Comments

-1

Microsoft removed VBA support from Office with v2008. iWork '08 has no Applescript support, and while I can't speak directly about v'09 given Apple's recent decline in scriptable applications I wouldn't count on it.

The sure, long-term bet here would be to use Excel with Applescript.

14 Comments

Thank you, Philip, but Excel 2011, the version I'm "about to plunk down money for", according to macworld (link below), restores VBA.
I still stand behind my recommendation to use Applescript. My experience has been that Applescript is actually easier (at least editor-wise). In addition, Applescript open to bringing in processes from other applications whereas VBA is very much limited to the Office suite.
I'm still curious - can a VBA script be launched from the command line (eg bash)?
If running a VBA script in Office is exposed in the Applescript API, then you could write a small script to run the VBA via osascript. That is, if there isn't something similar for VBA in bash, but I highly doubt MS went that far with their implementation.
OK thanks. Cool. So I bought Excel 2011. THEN I googled for "excel applescript reference". All hits are fore Excel 2004. Sigh. Shoulda googled first.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.