0

I have an application created in Omnis studio where I want the user to be able to press a button to open Microsoft Excel and then paste what is in the clipboard. To do that I have my application call an AppleScript app Seen here:

tell application "Microsoft Excel"
  activate
  make new workbook
  paste special on worksheet active sheet
end tell

However whenever my application calls that script it runs into issues with apple's sandboxing saying that it can't send events to Microsoft Excel.

I read online that in order to get access to sending events in Mac OS you need to have a entitlements.plist file associated with your application. How would I add a entitlements.plist file to my Applescript app so that when it is run it is able to send events to Microsoft Excel?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Jacob Edie
  • 69
  • 6

2 Answers2

0

If you do not sell the app and just use it for your own, best would be to deactivate sandboxing. Your app will still run by righclicking it > open.

If you already have sandboxing enabled there already must be a YOURAPPNAME.entitlements file inside your application structure (not in the compiled app, but in your source code) because sandboxing has to be enabled in that file.

I don't know Omnis studio, you may try using XCode instead which supports entitlements files from the scratch - even if you have to go with applescript objective-c instead of plain applescript.

if you manage to find that file you need to add a new key/value to it like so for addressing Excel:

key: "com.apple.security.temporary-exception.apple-events"
value (type array): 
    Item 0 > "com.microsoft.excel"

But watch out - if you want to stay in sandbox, from OSX 10.14 there's a new security policy called "security integrity protection" (SIP) by Apple where users also need to allow your app to automate other apps, checkout this thread: "because it is not SIP-protected" - Apple event error in OSX Mojave

To bypass this beginning from 10.14 you also have to add a new line to your info.plist file

key: NSAppleEventsUsageDescription
value: [Some description why you need to use AppleEvents]

I don't know if third party editors will follow the speed Apple provides in things of changes.

Pat_Morita
  • 3,355
  • 3
  • 25
  • 36
0

This is an older post, but why would you create an Excel file like that, if its just columns of data, just export a CSV file, that Excel can easily open...

Phil. P.
  • 46
  • 5
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/31376430) – tomerpacific Mar 29 '22 at 06:53
  • Hi, tomerpacific, I accept its not clearly an answer to the question, however, for an Omnis user point of view, it is probably the best way to achieve what the question is asking, on the Mac platform. Create a CSV and then open that document... unless there is some data that cannot be stored in CSV format. – Phil. P. Mar 29 '22 at 10:46