How to save an Excel Workbook Using Applescript

Hi Everyone! To save an Excel workbook to your desktop using AppleScript all you have to do is follow these few steps.

 

First you will have to define your workbook’s name!

 

set workbookName to ("My Workbook.xlsx") as string

 

If you wanted to save the workbook with today’s date you could do something like this

 

set today to (current date)

set workbookName to ("My Workbook " & month of today & "  " & day of today & ".xlsx") as string

Which would name your file “My Workbook December  16.xlsx”

Next you have to tell AppleScript where to save your document.

set destinationPath to (path to desktop as text) & workbookName

The above will allow you to save the document to your desktop.

Finally, to tell Excel to save your workbook type the following…

tell application "Microsoft Excel"

save active workbook in destinationPath

end tell

 

And you are done!

 

Putting it all together it looks like this:

set today to (current date)

set workbookName to ("My Workbook " & month of today & "  " & day of today & ".xlsx") as string

set destinationPath to (path to desktop as text) & workbookName

tell application "Microsoft Excel"

save active workbook in destinationPath

end tell

Samuel

Leave a Reply Text

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.