4

In earlier iterations of macOS I would use

open -a Finder.app <filename>

In Sonoma that is resulting in two of the following dialog boxes :

The application "Microsoft Word" can't be opened
-128

enter image description here

Note: the same document can be successfully opened directly from Finder.app by double clicking or hitting CMD-O . So Word is functioning properly and the document is intact.

I did look at some microsoft-learn pages and they do not address this scenario.

How to open a Microsoft Word document from the commandline in Sonoma?

4
  • 4
    What's wrong with open path/to/doc? Also see apple.stackexchange.com/questions/212583/…
    – Tetsujin
    Commented Jan 28 at 18:12
  • @Tetsujin That actually works in sonoma: it did not in earlier iterations of macOS. Commented Jan 28 at 21:50
  • 2
    It worked in 2015, as per the linked answer!
    – benwiggy
    Commented Jan 29 at 8:04
  • @WestCoastProjects It's essentially equivalent to double clicking on the document, so it should have worked forever. The only issue would be if you changed the "open with" application for the document.
    – Barmar
    Commented Jan 29 at 15:38

2 Answers 2

3

I would type open then drag the document to the shell. (Skip the app entirely)

See if the full path opens, no need to involve Finder. Worst case specify “Microsoft Word” as the app to open the document.

2
  • yea that works now. In past iterations it did not. thanks. Commented Jan 28 at 21:49
  • 1
    Wonderful @WestCoastProjects launch services can be odd indeed…
    – bmike
    Commented Jan 29 at 0:03
14

I think that -a Finder.app is an incorrect syntax. You don't want to open it 'in' the Finder, you want to open it in Word.

The following works for me in Sonoma:

open -a "Microsoft Word.app" document.docx

open document.docx (as Word is the default).

That having been said, open -a Finder.app document.docx also works for me in Sonoma, briefly revealing a Finder window of the enclosing folder, before Word then launches and the file is loaded.

Obviously, this is for a document.docx that's in the current directory, or contains a full filepath.

It's possible that it's not working for you because of a Launch Services DB corruption, or a file cache or something.

5
  • The open -a <app name> syntax has apparently changed. I used Finder.app because that did actually work [better] for several iterations of macOS. Apparently simply open is fine now. Commented Jan 28 at 21:50
  • 1
    @WestCoastProjects The man page for open is dated 2017. I've used those options for many years. I'd recommend resetting your LaunchServices database.
    – benwiggy
    Commented Jan 29 at 8:03
  • 3
    The open syntax for this has not changed since 2000 (and I suspect since 1990 from NeXT)
    – mmmmmm
    Commented Jan 29 at 8:49
  • 2
    I don’t think that .app is necessary.
    – Carsten S
    Commented Jan 29 at 14:14
  • 1
    @CarstenS The example in the man pages includes it, but you're right, it isn't necessary.
    – benwiggy
    Commented Jan 29 at 16:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .