I have a script (running from osascript) that opens an existing spreadsheet, changes some values and saves it to a new filename.
However, I can't get it to save properly. If I use a string, it will save to a new filename, but if I use a posix path, it saves over the top of the existing file!
Per the below, if I change "outputFile" to "newPathString", it will happily save with as ":Users:foo:bar:out-11.xls", ie. a file with those chars in current directory.
Am I missing some nuance here? It's particularly odd since the open inputFile bit works fine...
thanks!
Nathan
#!/bin/sh
osascript <<DONE
set oldPathString to "/Users/foo/bar/" & "in-$month.xls"
set newPathString to "/Users/foo/bar/" & "out-$month.xls"
set inputFile to posix file oldPathString
set outputFile to posix file newPathString
tell application "Microsoft Excel"
open inputFile
tell worksheet "Sheet1" of active workbook
-- change values
end tell
tell active workbook
save workbook as filename outputFile
end tell
end tell
DONE