title: Trying to use VBA to Open a PowerBI File, Refresh it, and Save it?
body: <p>I am trying to open a .pbix file that sits on a network drive, refresh the PowerBI connection to the file, then close the file and save the changes. I am trying to run the process from Excel, because Excel does some things, propr to this refresh task. I am testing the code below, which I think is pretty close, but I an getting this error message:</p>
  <p>RUN TIME ERROR: 424 Object Required</p>
  <pre><code>Public vPID As Variant
  
  Sub Launch_Calculator()
  Dim fileString as String
      If IsProcessRunning(&quot;C:\Program Files\PBIDesktop.exe&quot;) = True Then
          On Error GoTo Reload                ' Open new instance of PBIX
          AppActivate (vPID)                  ' Reactivate, using Public declared variant
          SendKeys &quot;%{Enter}&quot;                 ' Bring it back into focus if user minimises it
      Else
  Reload:
      fileString = &quot;&quot;&quot;\\network_path_here\testing.pbix&quot;&quot;&quot;  
      strFileName = CreateObject(&quot;WScript.Shell&quot;).Specialfolders(&quot;\\network_path_here\&quot;) &amp; &quot;testing.pbix&quot;
  
      ' fileString.Open...got RUN TIME ERROR: 424 Object Required
      ' strFileName.Open...got RUN TIME ERROR: 424 Object Required
  
      End If
      On error GoTo 0
  End Sub
  
  
  ' Function to check for running application by its process name
  Function IsProcessRunning(sApp As String)
  On Error GoTo Skip
      Dim objList As Object
      Set objList = GetObject(&quot;winmgmts:&quot;) _
          .ExecQuery(&quot;select * from win32_process where name='&quot; &amp; sApp &amp; &quot;'&quot;)
      If objList.Count &gt; 0 Then
          IsProcessRunning = True
          Exit Function
      Else
          IsProcessRunning = False
          Exit Function
      End If
  Skip:
  IsProcessRunning = False
  End Function
  </code></pre>
  <p>So, I can open the PowerBI.exe file, and run the application just fine, but I can't open and refresh the '.pbix' file. How can I open the .pbix file, refresh it, and save it?</p>