Saving an Excel 2004

In a reply to an earlier post, digest4d gave me some great ideas to a problem I was having with Applescript and Excel 2004 (Thanks!) I was attempting to pass some variables from a VBA macro in Excel to another program. Digest4d pointed out that VBA will not pass variables to other applications and I should look at building my script in Applescript.

As a programming novice, I used the holiday we received from Hurricane Dennis (we were in the path, but no damage) to blunder through creating that script. It almost works!

Here is my current trouble spot in my script. I open an Excel spreadsheet in my script then save it as file01 as a text file using this line:

save workbook in file01 as text Mac file format

It works, but it pops several information windows asking if I want to save, asking where I want to save to letting me know that some features of worksheets cannot be saved in a text file.

How can I force the save without the questions?

In the Excel 2004’s dictionary for the save worksheet as command, there is an entry for something called conflict resolution. It sounds as if this may be the answer to my question, but I cannot figure out how to format that line.

Can you help? How can I format the “save” command in Excel 2004 and Applescript so that the script will execute the save without asking me to click on a bunch of information windows about that save operation.

Thanks for your help.


Model: i
Browser: Firefox 1.0.4
Operating System: Mac OS X (10.4)

Conflict resolution isn’t it – that’s the workbooks pref on what happens when two users update the same data in a shared document. Some apps have a command like “set user interaction level”, but I don’t think Office does.

You shouldn’t be getting those dialogs. Try supplying a fully-qualified path. Make sure the file doesn’t already exist. You’re supplying just a file name, which is not a “Macintosh Path” OR a “Posix Path”. (See dictionary below.)

Also, what happens if you just say “text Mac” instead of “text Mac file format”? Not sure about the correct syntax, I’m not sure the words “file format” are needed.

Excel Dictionary/Standard Suite Commands…
save: Save an object
save reference – the object to save
[in Macintosh path/Posix path] – the file in which to save the object
[as add in/CSV/CSV Mac/CSV MSDos/CSV Windows/DBF2/DBF3/DBF4/DIF/Excel2/Excel2 east asian/Excel3/Excel4/Excel5/Excel7/Excel9795/Excel4 workbook/intl add in/intl macro/workbook normal/SYLK/template/current platform text/text Mac/text MSDos/text printer/…] – the file type of the document in which to save the data

tell application “Finder”
duplicate “Macintosh HD:WordCounts.xls” to “Macintosh HD:wcreport” with replacing
end tell
tell application “Microsoft Excel”
open “Macintosh HD/wcreport/WordCounts.xls”
save as add in / Excel4 workbook
end tell

The second to last line doesn’t work. Any suggestions?