Share via

How to execute a shell command in Excel 2016 for Mac

Anonymous
2015-07-14T08:26:48+00:00

In Excel 2011 for Mac, you could either use a system call or MacScript("do shell script ""command"""), see http://stackoverflow.com/a/12320294/918626.

In Excel 2016 for Mac, I can still do: MacScript ("do shell script ""open /Applications/Calculator.app"" ") but already something like MacScript ("do shell script ""source ~/.bash_profile;open /Applications/Calculator.app"" ") fails (which worked on 2011).

I saw http://stackoverflow.com/a/30949324/918626 regarding MacScript in general, but I wonder if it is also the easiest way to call a shell command?

Microsoft 365 and Office | Excel | For home | MacOS

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

2 answers

Sort by: Most helpful
  1. Anonymous
    2015-07-17T23:11:51+00:00

    Yeah, I made the same experience... system and MacScript seem to both work for very simple things. AppleScriptTask was about the same experience... unfortunately....

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2015-07-14T12:29:02+00:00

    As Ramit explains Office 2016 runs in a sandbox which means it only gets access to predefined resources.

    Checking the sandboxd messages in Console can help to determine why an operation failed. I suspect there isn't ONE best way to call a shell command as it depends on what the scripts does.

    UPDATE: Within the limits of the sandbox a system() call still seems to work. Leaving the sandbox is possible using AppleScriptTask in theory. However, I couldn't get it to work reliably with anything but the most basic script.

    Was this answer helpful?

    0 comments No comments