For Excel V15, use a posix path, like this:
set theOutputPath to POSIX path of ((path to desktop folder as string) & "My Saved Workbook.csv")
tell application "Microsoft Excel"
tell active workbook
save workbook as filename theOutputPath file format CSV Mac file format with overwrite
end tell
end tell
Edit 1 -
I test it on V15.15 and V15.16, it's a bug when the destination folder doesn't contains a recently opened Excel file.
So use it
set theOutputPath to POSIX path of ((path to desktop folder as string) & "My Saved Workbook.csv")
set parentFolder to (do shell script "dirname " & quoted form of theOutputPath) as POSIX file -- get the parent folder
tell application "Microsoft Excel"
alias parentFolder -- a folder where to save a new file, workaround to a bug when the destination folder doesn't contains a recently opened Excel file
save workbook as active workbook filename (theOutputPath) file format CSV Mac file format with overwrite
end tell
Edit 2 -
Or create an empty file like this
set theOutputPath to POSIX path of (path to desktop folder as string) & "My Saved Workbook.csv"
do shell script "touch " & quoted form of theOutputPath -- create an empty file
set theOutputPath to theOutputPath as POSIX file
tell application "Microsoft Excel"
save workbook as active workbook filename (theOutputPath) file format CSV Mac file format with overwrite
end tell
Edit 3 : I had another idea, it would be the simplest script.
set theOutputPath to (path to desktop folder as string) & "My Saved Workbook.csv"
tell application "Microsoft Excel"
alias theOutputPath -- workaround to a bug when the destination folder doesn't contains a recently opened Excel file
save workbook as active workbook filename theOutputPath file format CSV Mac file format with overwrite
end tell
Best Answer
Assuming you have a valid/consistent CSV file, create a new workbook and then choose File -> Import. The first option on the list is "CSV file":