-1

I'm trying to open a pbix file through a VBA code after updating an excel database. I used the following commands in VBA:

MyFile = "filepath"
Cmd = "RunDLL32.EXE shell32.dll,ShellExec_RunDLL "
Shell (Cmd & MyFile)

When I execute the code and Power BI initiates, an error message saying "Ribbon view has not been initialized" appears, and the software doesn't work properly. In order to have it working I need to close it and then open it manually.

Do you have any idea why I'm having this error? Is it the method I'm using to open the file? Do you know another way to do it?

Thanks,

  • Why do you need to open the Power BI file in the first place? Power BI can refresh the queries when the PBIX file is opened by the owner. That's what it does. Refresh data from different sources. What's the point of opening the file with code? – teylyn Dec 19 '18 at 19:46
  • My Idea was to run this part of the code in order to open the pbix file so that I can hit the refresh button in power BI. Without this I would have to find the pbix file, open it manually and then perform the refresh. I just want to save time. – Rafael Venturini Dec 19 '18 at 19:50
  • Surely, if you can find the file with code, you can find it in Explorer? How about a shortcut on your desktop or in the Quick access panel? – teylyn Dec 19 '18 at 19:53
  • As I said, I want to save time. The complete code is running SAP transactions to extract information and make it available to my power BI dashboards in this pbix file. I takes time to do that, and I wanted the code already to open the pbix file when it's done extracting the info, because I don't intend to watch the whole extraction process to know that I can start power BI (it takes a considerable time to open power BI). – Rafael Venturini Dec 21 '18 at 01:15

1 Answers1

0

I found another way to open files in VBA that worked. I found it in: How can Excel VBA open file using default application

See below the solution:

Dim Shex As Object
Set Shex = CreateObject("Shell.Application")
tgtfile = "filepath"
Shex.Open (tgtfile)

Thanks