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.
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')
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') )
22 thoughts on “Open Word documents in the desktop app from Power Apps”
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?
That should all be the same. Can you check the uri that you are using?
[…] Source link […]
Can you launch them in the browser but as read view?
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.
Can this work with a hyperlink stored in a text field, which is linked to a document LIbrary?
Yes, it can be use to open a link. I often use it using the link to item property of a document in a library.
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?
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
Does this still work ?
Launch(“ms-word:ofe|u|” & ThisItem.’Link to item’ );
I have troubles to make it work.
“Link to item” attribute returns link with an id at the end, which seems to make a problem for a Desktop Word to open.
word opens some new file as read only not that one which is pointed.
When I use
Launch(ThisItem.’Link to item’ );
with browser version works as expected.
Any suggestions ?
Do you get any errors when the Launch is failing?
No error. It opens a Word, but the proper file is not open, only just some empty file.
When I have provided a static value to Launch function (path + file without id) it works.
Launch(“ms-word:ofe|u|” & “https://xxxxx.sharepoint.com/sites/documents-xxx/xxxxxx/100%20folder/word-file.docx”);
Do you have any idea what could be wrong here ?
If without the id it works then you could do something like this:
Yes meanwhilel I have done such like this.
Just wondering what happened to orgin call
Set(varOfficeItem, First(Split(ThisItem.’Link to item’,”?d=”)).Result);
Launch(“ms-word:ofe|u|” & varOfficeItem );
Hi Pieter, thank you for the guide, i have a question for you, is possible open PDF document in desktop app like this? Thank you in advance.
You could use browser settings to switch the document opening to the PDF applications as described in the below post:
Thanks for the reply, but the software is not for me, but for my company, im not the final user, there is some comand like “ms-word:ofe|u|” but for PDF?
I don’t think that that exists
I am trying to open the Word document in a desktop app, when i use Launch(“ms-word:ofe|u|” & ThisItem.’Link to item’) I get the following error message: “Access denied. Contact your administrator” I am the owner of the document.
When I use the document’s SharePoint link it works but it pulls up the original template and we need it to generate a version that people can edit without overriding the template.
That should be ok. Can you send me the full link. Feel free to send it on the chat rather than here in the comments.
Thanks for the solution, it worked for Word files and Excel files, Can you give me expression for ,txt to open in notepad and PPTs to open in powerpoint?
The following link will give you some of the options available. I don’t think that notepad is an option available: