Open Word documents in the desktop app 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')
)

Continue Reading Pieter Veenstra’s Article on their blog

Open Word documents in the desktop app 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? In my app I have created a gallery that displays the icons and the name of the documents.

Blog Syndicated with Pieter Veenstra’s Permission

Author: Pieter Veenstra

Share This Post On