I am new to applescript but have managed to write a droplet that takes all excel files, strips away all unneeded data and saves the results. I have created a second script that creates a graph in an app called Chartsmith. To join these two scripts together I need to save the excel file as a CSV file. I have read the microsoft scripting guide and the resulting script runs without any errors and it does save the file but not in CSV format.
Here is a script showing only the problem lines:
tell application "Microsoft Excel"
set new_Book to active workbook
save workbook as new_Book filename "test.csv" file format CSV file format
end tell
I use Excel 2004.
Thanks for any help,
Matt.
Model: G5 1.6
AppleScript: 1.10
Browser: Safari 412.5
Operating System: Mac OS X (10.4)
Thanks Dave that sorted it. I guess I should have tried - as CSV - but the microsoft guide to scripting Excel suggests a totally different syntax.
Here is the first half of the script in case your interested which works really well now. All I have to do now is change the cell deletion section to tailor it to different tasks.
on open (drop_files)
repeat with EachItem from 1 to the count of drop_files
set filePath to item EachItem of drop_files as alias
tell application "Microsoft Excel"
activate
-- open dropped files
open workbook workbook file name "" & filePath
--get sheet name
set Name_of_sheet to name of active workbook
-- remove file extension
set Name_of_sheet to name of active workbook
if text -4 of Name_of_sheet is "." then
set Name_of_sheet to (text 1 thru -5 of Name_of_sheet)
end if
-- get rid of unwanted cells
activate object workbook 1
delete column "C:N" of sheet 1
delete column "D:U" of sheet 1
delete row "2:4" of sheet 1
delete row "6:10" of sheet 1
-- save with new file name as CSV type
save workbook in "Macintosh HD:Users:matt:Desktop:Apoptosis_graphs:" & "adjusted_" & Name_of_sheet & ".csv" as CSV
-- close the sheet
set CloseSheet to active workbook
set saved of CloseSheet to true
close active workbook
end tell
end repeat
end open