0

I want to open a Power BI report by clicking on an Excel button. The report is on the server, so we use SharePoint and teams to get the files.

The .pbix file is also put on Teams and I don't know how to open it directly from the Excel button.

The report used to be local so I used this code to open it:

Sub cmdOpen_Click()

VBA.Shell "C:\Program Files\Microsoft Power BI Desktop\bin\PBIDesktop.exe C:\Users\nizar\Desktop\KPI.pbix"

End Sub

Now the report is on Teams.

I can open it as a link, but it will only lead me to Teams where the report is placed, but I want it to open it directly on the application.

Community
  • 1
  • 1

1 Answers1

0

A Teams folder is actually a Sharepoint folder in disguise:

So you should be able to browse to the folder that contains your file in Teams, and then using the menu you should be able to select "Open In Sharepoint": enter image description here

From there, you would use the normal methods of converting a Sharepoint address into a file location.

For example:

https://yoursite.sharepoint.com/sites/sitename/document_library/subfolder/test.pdf

Would become:

\\yoursite.sharepoint.com@ssl\sites\sitename\document_library\subfolder\test.pdf

CLR
  • 11,284
  • 1
  • 11
  • 29
  • How can I convert the Sharepoint adresse into a file location, knowing that +23 people will be using the report. – Nizar El aouina Aug 30 '22 at 15:28
  • I've added an example of what to change when converting a sharepoint resource location to a filename. Beyond that, search for answers and you will find them. https://stackoverflow.com/a/24221462/7446760 would be a good start, though I'm not sure that example handles converting `%20` to a space - but it could be added – CLR Aug 30 '22 at 15:58
  • Yes, i saw your example, but I don't think it would fit in my code since VBA.Shell opens a .exe file. So is there a simple way to fix this. Btw thanks for the link of that question, that seems interesting. – Nizar El aouina Aug 31 '22 at 11:50
  • Yes, I know shell is used to run `PBIDesktop.exe`, but the issue I assume you're having is the *filepath/name* of the *file* you want to open. You need to swap out the `C:\Users\nizar\Desktop\KPI.pbix` part of your example line with the correct sharepoint file address, once it's converted to a UNC filepath using the above. – CLR Aug 31 '22 at 11:53
  • Update : I tried the code and adapted the path to the example you gave me. It actually runs power bi desktop, but they're telling me the file may be broken, while it's definitely not. – Nizar El aouina Aug 31 '22 at 12:42
  • Do I have to delete what comes after ? in the file path – Nizar El aouina Aug 31 '22 at 12:46
  • Yes, you shouldn't pass any sharepoint parameters. Also, if your filename contains a space, you're going to want to wrap it in quotes eg. `VBA.Shell """PowerBI_location"" ""File_Location"""` – CLR Aug 31 '22 at 13:41
  • But when I had the file located on my computer I didn't have any problems with the spacings. Do you think I should do it even though? – Nizar El aouina Aug 31 '22 at 14:08
  • It's always recommended. Perhaps its not required if the PowerBI exe only ever expects a single parameter - in which case you're good without it. – CLR Aug 31 '22 at 14:39
  • Yeah, so I think this won't work because they're telling me that my file is corrupted or encrypted, and when I try to remove the information protection, I don't even have the button to disable it, as this [site](https://community.powerbi.com/t5/Desktop/pbx-file-cant-be-opened-Either-the-file-is-corrupted-or/td-p/1544541) shows. And I think that the reason is because the company didn't buy the pro license, so I don't think there's a way to solve this unless the company buys the pro license – Nizar El aouina Aug 31 '22 at 16:42