Skip to content

File extension association to LibreOffice calc in macOS

  • by
Spread the love

Calc is not a separate standalone application as in what Excel is in Microsoft Office or like Numbers, which are fully functional standalone applications. As such, there is no default method thru Finder, Get Info and or Open With in macOS to associate a particular file extension with Calc, as it is just not a fully functional standalone application as with the aforementioned applications.

In your particular use case, the only practical reason to associate a give file extension with a given application is to be able to either double-click the file or press ⌘O in Finder and have it open in it. As that is not doable by the methods previously mentioned, an alternative is to select the file in Finder and either select a Service/Quick Action or press a keyboard shortcut and have the selected file open in the given application. If one is already in Finder then this certainly is much quicker and easier then going thru the application to open the file.

The following example AppleScript code, shown below, can be used in various ways, however, this will focus on creating an Automator Service/Quick Action and also assigning it a keyboard shortcut.

  1. In Automator, create a new Quick Action, as shown in the screen shot below the Notes: section, with the following settings: Workflow receives [no input] in [Finder]

  2. Add a Run AppleScript action, replacing the default code with the example AppleScript code, show below.

  3. Save the Quick Action as e.g.: Open in Calc

  4. Then assign it a keyboard shortcut in System Preferences > Keyboard > Shortcuts > Services, e.g.: ⌃⌥⌘O

  • Note: The first time using the Service/Quick Action I recommend not use the keyboard shortcut and after selecting the target file in Finder, then either from Finder > Services click e.g. Open in Calc, or it is available on the context menu, right-click the file and select it from Quick Actions or Services. After dealing with the Security & Privacy related prompts one can then use the keyboard shortcut.

Example AppleScript code:

set selectedItems to {}

tell application id ""
    set selectedItems to selection as alias list
end tell

if selectedItems is {} then return

set posixPathOfLibreOffice to ¬
    the POSIX path of the (path to ¬
        application id "org.libreoffice.script")

set shellCMD to {¬
    "'", posixPathOfLibreOffice, ¬
    "/Contents/MacOS/soffice", "'", ¬
    space, "--calc", space} as string

repeat with thisItem in selectedItems
    set thisItem to the POSIX path of the contents of thisItem
    tell application id "org.libreoffice.script" to activate
    do shell script shellCMD & thisItem's quoted form
end repeat


The example AppleScript code, shown above, was tested in Script Editor and as an Automator Service/Quick Action under macOS Catalina with Language & Region settings in System Preferences set to English (US) — Primary and worked for me without issue1.

  • 1 Assumes necessary and appropriate settings in System Preferences > Security & Privacy > Privacy have been set/addressed as needed.

The example AppleScript code can also be used as an AppleScript application and placed in the Toolbar of Finder, thus allowing it to be clicked after selecting the target file. I do this with some of the AppleScript scripts I use daily in Finder as it’s the easiest method to automate what manually takes many more steps and time.

Automator Service/Quick Action:

Note: The example AppleScript code is just that and sans any included error handling does not contain any additional error handling as may be appropriate. The onus is upon the user to add any error handling as may be appropriate, needed or wanted. Have a look at the try statement and error statement in the AppleScript Language Guide. See also, Working with Errors. Additionally, the use of the delay command may be necessary between events where appropriate, e.g. delay 0.5, with the value of the delay set appropriately.

Leave a Reply

Your email address will not be published. Required fields are marked *