OK Here's for some homework
First script creates the whole file in Excel then opens the save as dialog.
// make xls file on mac// http://forums.adobe.com/message/5610204#5610204// http://www.mactech.com/articles/mactech/Vol.23/23.02/2302AppleScript/index.html was a big help// http://macscripter.net/viewtopic.php?id=39768 also helpedif (($.os.match(/Mac/i)) { var rangeContents = '{{"My Text File opened in excel"},{"This is cell A:2", "This is cell B:2", "This is cell C:2"}, {"This is cell A:3", "This is cell B:3", "This is cell C:3"}, {"Thanks a million""}}'; var myAppleScript2 = 'tell application "Microsoft Excel"\r' + 'set theWorkbook to make new workbook\r' + 'tell active sheet of theWorkbook\r' + 'set value of range "A1:C4" to ' + rangeContents + '\r' + 'autofit columns\r' + 'end tell\r' + 'show (get dialog dialog save as)\r' + 'end tell\r' ; app.doScript (myAppleScript2, ScriptLanguage.APPLESCRIPT_LANGUAGE); }
Second script Opens Text file with Excel then saves it as an excel file. @Ariel might get to see if my mac saveas function works.
// For Mac Open txt File with Excel and Save as xls// http://forums.adobe.com/message/5610204#5610204// http://www.mactech.com/articles/mactech/Vol.23/23.02/2302AppleScript/index.html was a big help
txtFileContents = "My Text File opened in excel\nThis is cell A:2\tThis is cell B:2\tThis is cell C:2\nThis is cell A:3\tThis is cell B:3\tThis is cell C:3\nThanks a million\n"; if ((textFile = saveFile (txtFileContents)) && ($.os.match(/Mac/i)) && (confirm ("Do you wish to open the text file in Microsoft Excel? ", false))) { var macFileName = textFile.fsName.replace(/\\/g, ":").replace(/::/, ":"); // highly doubt the replaces are neaded Please can you test, var macXlsFileName = macFileName.replace(/txt$/i, "xls"); var myAppleScript1 = 'tell application "Microsoft Excel"\r' + 'open text file filename "' + macFileName + '" data type delimited tab true\r' + 'tell active sheet\r' + 'autofit columns\r' + 'end tell\r' + 'tell active workbook\r' + 'save workbook as filename "' + macXlsFileName + '"file format Excel98to2004 file format\r' + 'end tell\r' + 'end tell\r' ; app.doScript (myAppleScript1, ScriptLanguage.APPLESCRIPT_LANGUAGE); }
function SaveDialog (myFilePromt /* The file promt" */ ,Preset /* The desired suffix */ , warning /* OPTIONAL if true warn on overwrite, defalt is FALSE */) { var suffix = Preset.match(/[^.]*$/), regSuffix = new RegExp("\\." + suffix + "$", "i"), myFile = ($.os.match(/Mac/i)) ? File.openDialog (myFilePromt, function (f) {return (f instanceof Folder) || f.name.match(regSuffix);}) // if Mac : File.saveDialog (myFilePromt, [Preset]); // else if (myFile) { var myFileName = myFile.name; if (! regSuffix.test(myFileName)) myFile = File (myFile.path + "/" + myFileName += "." + suffix); if (myFile.exists) { if ($.os.match(/Mac/i) && myFile.readonly) { alert (myFile.name + "\rThis file is set to read-only.\rTry again with a different file name."); SaveDialog (myFilePromt, Preset, warning); }; elseif (warning) if (!confirm ("The file " + File.decode(myFile.name) + "\nexists, do want to overwrite it? ", false, "Comfirm Save")) SaveDialog (myFilePromt, Preset, warning); } return myFile; } }
function saveFile (fileContents) { var myNewFile = SaveDialog ("Please enter then name of text file to save."// The file save prompt --- Change as desired ,"Text:*.txt"// The filter --- Change as desired , true) // OPTIONAL if true give warn on overwrite, default is FALSE if (myNewFile) // save file if cancel was not pressed { var mod; mod = (myNewFile.exists) ? myNewFile.modified.toString() : 0; myNewFile.open('w'); myNewFile.write(fileContents); myNewFile.close(); if (myNewFile.modified.toString() == mod) { alert((File.decode(myNewFile)) + "\nWAS NOT SAVED\n(Check if the file is readonly or open)"); saveFile (); } return myNewFile // file saved } returnfalse// file not saved }
Scripts are completly untested
Chance of them working:- Not so great
Script 3:
Sorry about this one completly off the topic, not a mac specific script and nothing to do with excel or the original question
BUT if someone could test it on a NON-ENGLISH computer it would be a very big help to me.
The script retrieves the date from an Internet site.
The Results on the js console by me look like this
***************************************
Start Time: 1377020918626
Local Time: Tue Aug 20 2013 20:48:38 GMT+0300
Server Time: Tue, 20 Aug 2013 17:48:38 GMT
End Time: 1377020918627
Total Time: 0.001 seconds
***************************************
What I need to know is how the dates are displayed on the non English systems
Here's the Link to that script. (The Link will only be valid for a day or 2)
I really appreciate the help
If the mac scripts work I shall try working on Windows wich I can test myself.
Thanks again
Trevor