• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Best way to script Excel 2016 from Python
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Best way to script Excel 2016 from Python


  • Subject: Re: Best way to script Excel 2016 from Python
  • From: Felix Zumstein <email@hidden>
  • Date: Fri, 27 Mar 2015 11:04:29 +0100

Hi Christopher,

thanks for getting back to me. I think my snipped is OK too (it works with 2011), I took it directly from the book "Learn AppleScript" by Hamish Sanderson & Hanaan Rosenthal (you're certainly right about the directory). Anyhow - your snipped shows exactly the same behavior - works with 2011 but doesn't create the file with 2016 plus shows the "Document not saved." error when trying to resave the file manually... 

On Fri, Mar 27, 2015 at 10:54 AM, Christopher Stone <email@hidden> wrote:
On Mar 27, 2015, at 04:26, Felix Zumstein <email@hidden> wrote:
But I discovered an issue with AppleScript directly - saving doesn't work properly:

tell application "Microsoft Excel"
    set new_book to make new workbook
    save workbook as new_book filename "test.xlsx"
end tell
______________________________________________________________________

Hey Felix,

I think you've missed the correct syntax, but I'm testing in Excel 14.4.8 - so you'll have to double-check.

When you create new_book it is already of class workbook, so you don't need to refer to it as workbook <name>.

In any case this syntax is incorrect:

save workbook as new_book filename "test.xlsx"

This works:

-----------------------------------------
set saveDir to path to downloads folder as text
set newExcelFilePath to saveDir & "test.xlsx"

tell application "Microsoft Excel"
  activate
  set new_book to make new workbook
  save new_book in newExcelFilePath
end tell
-----------------------------------------

If you don't give Excel the full path to the new file it will be saved in the last directory where a file was manually saved.

--
Best Regards,
Chris


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Best way to script Excel 2016 from Python
      • From: Christopher Stone <email@hidden>
References: 
 >Re: Best way to script Excel 2016 from Python (From: has <email@hidden>)
 >Re: Best way to script Excel 2016 from Python (From: Felix Zumstein <email@hidden>)
 >Re: Best way to script Excel 2016 from Python (From: Christian Prinoth <email@hidden>)
 >Re: Best way to script Excel 2016 from Python (From: Felix Zumstein <email@hidden>)
 >Re: Best way to script Excel 2016 from Python (From: Christopher Stone <email@hidden>)

  • Prev by Date: Re: Best way to script Excel 2016 from Python
  • Next by Date: Re: Best way to script Excel 2016 from Python
  • Previous by thread: Re: Best way to script Excel 2016 from Python
  • Next by thread: Re: Best way to script Excel 2016 from Python
  • Index(es):
    • Date
    • Thread