Services and sandboxing

Following Episode 588 I was inspired to try to write some text services to automate bits of my workflow.

Assume for the sake of argument that I’ve written a text service in Automator called “Speak Text” which accepts text in any application, and has a single “Speak Text” action which speaks the input.

If I now right-click on some selected text in Microsoft Word, I can see the action. I click it. I get two error dialogs almost simultaneously, one saying “The “Speak Text” Service could not be used” and the other “There was a problem with the input to the Service”.

Poking around in the Console I can see what the problem is: Word is trying to read the service workflow file, and the sandbox is blocking it:

Sandbox: Microsoft Word(2590) deny(1) file-read-data /Users/NAME/Library/Services/Speak Text.workflow
Violation:       deny(1) file-read-data /Users/NAME/Library/Services/Speak Text.workflow
Process:         Microsoft Word [2590]
Path:            /Applications/Microsoft Word
Load Address:    0x10bf8e000
Version:         16.49.21050901 (16.49)
Code Type:       x86_64 (Native)
Parent Process:  launchd [1]
Responsible:     /Applications/Microsoft Word
User ID:         502

Date/Time:       2021-05-20 14:34:14.438 GMT+1
OS Version:      macOS 11.3.1 (20E241)
Report Version:  8

I’ve already given Word full disk access in the security System Preferences pane, but that doesn’t help.

Editing the Word app to remove sandboxing (which if I can do it will presumably work) feels like a bad (and very fragile) approach, but I don’t have any other ideas.

For what it is worth this isn’t just confined to Word: I see the same problem with Preview. But Word is what I want to get working.

Help/thoughts much appreciated!

These settings in System Preferences > Accessibility will turn on the feature to speak the selected text on the screen in any application. The default keyboard shortcut is Option+Esc, and that can be changed in the “Options” for “Speak selection”.

This was the method recommended by Microsoft for Word 2016 and continues to work in the current versions of Word for Mac.

1 Like

Thanks! Unfortunately I want to be able to do more than just speak text: I was really using it as a placeholder for a much more complicated text workflow. Hence trying to use Automator and the sandbox problem above.

Can you post the Automator code?

1 Like

I don’t think you’re alone. The discussion forums have a lot of threads with Word/Automator frustrations.

Years ago, under OS X, there were Automator actions packaged with Word and the other Office apps. No more.