Open documents in Word from Power apps

When you open Word documents from Power Apps you might have noticed that Word Online is used, but can we open documents in the Word Desktop app instead?

Displaying Word documents

In my app I have created a gallery that displays the icons and the name of the documents.

Open Word documents in the desktop app from Power Apps Microsoft Office 365 image

Now there is a property available ThisItem.’Link to item’ to open a document. And Using the Launch function. We can open the document.

Launch(ThisItem.'Link to item')

But this will open in Word Online and many users would like to open documents in the desktop app instead.

Creating icons for documents

Ok, before I continue, did you know that you can get the icons by using the following code?

"https://res-1.cdn.office.net/files/fabric-cdn-prod_20220127.003/assets/item-types/32/" & Last(Split(ThisItem.'File name with extension',".")).Result & ".png" 

With the above code the icons will be read from your SharePoint tenant. So that is easier than other solutions that I’ve seen people use to make icons appear.

Open Word documents in the Desktop app

To open the Word app rather than Word online, all I have to do is add ms-word:ofe|u| to the url that I’m calling as mentioned in this post.

So to make this work I configured the OnSelect of the file name label to use the following code.

Launch("ms-word:ofe|u|" & ThisItem.'Link to item')
Open Word documents in the Desktop app

And now when I click on the label, my document is opened within the Word desktop app.

Open Excel spreadsheets in the Desktop app

The same solution also works for spreadsheets:

Launch("ms-excel:ofe|u|" & ThisItem.'Link to item')

Handling the different file types

So if you now want to handle the different file types you could use code like this:

If(
    Last(
        Split(
            ThisItem.'File name with extension',
            "."
        )
    ).Result in [
        "docx",
        "doc"
    ],
    Launch("ms-word:ofe|u|" & ThisItem.'Link to item'),
    Last(
        Split(
            ThisItem.'File name with extension',
            "."
        )
    ).Result in [
        "xlsx",
        "xls"
    ],
    Launch("ms-excel:ofe|u|" & ThisItem.'Link to item')
)
Avatar for Pieter Veenstra

By Pieter Veenstra

Business Applications and Office Apps & Services Microsoft MVP working as a Microsoft Productivity Principal Consultant at HybrIT Services. You can contact me using contact@veenstra.me.uk.

9 thoughts on “Open Word documents in the desktop app from Power Apps”
  1. Hi! This seems to work when I do it manually from SharePoint. But I can’t get it to work within Power Automate and an Adaptive Card. Is that a limitation, or am I missing a trick for that?

    1. Hi Ben, without that msword prefix mentioned in the post documents will open in the online version. If you want them to be read only then I would use permissions on the files.

  2. Can this work with a hyperlink stored in a text field, which is linked to a document LIbrary?

      1. pieter, silly question how can I do this. I am using a list to record all the meta data for a documents history (Approvals, rejections, revision history, etc.) this list is linked to a Power App, which has a linked workflow through which user upload documents into a specific library, and with this I create a hyperlink to the document. (This link cannot be clicked in edit mode – so I created a text label to allow me to do this. But the item opens online. This is really what I need to have open in the desktop app to allow reviewers to make minor amendments before it goes through an approval loop.

        I Tried the code above and couldn’t get it to work?

      2. Pieter – I can get the file to download from a link and open, BUT what I need is for the file to open from the Library in the desktop App so that the reviewers can perform minor edits without having to reupload the document, how can this be done – I can do this from a SharePpoint page list view, but I need to be able to do it within a Power App. I create a link through a workflow, submit an item to SharePoint and then update the list item data within the same power app later, when the link has been turned into an APP. At the moment I am using an html text box to create a clickable link within the App

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.