'Trying to use VBA to Open a PowerBI File, Refresh it, and Save it?

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:

RUN TIME ERROR: 424 Object Required

Public vPID As Variant

Sub Launch_Calculator()
Dim fileString as String
    If IsProcessRunning("C:\Program Files\PBIDesktop.exe") = True Then
        On Error GoTo Reload                ' Open new instance of PBIX
        AppActivate (vPID)                  ' Reactivate, using Public declared variant
        SendKeys "%{Enter}"                 ' Bring it back into focus if user minimises it
    Else
Reload:
    fileString = """\\network_path_here\testing.pbix"""  
    strFileName = CreateObject("WScript.Shell").Specialfolders("\\network_path_here\") & "testing.pbix"

    ' 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("winmgmts:") _
        .ExecQuery("select * from win32_process where name='" & sApp & "'")
    If objList.Count > 0 Then
        IsProcessRunning = True
        Exit Function
    Else
        IsProcessRunning = False
        Exit Function
    End If
Skip:
IsProcessRunning = False
End Function

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?

vba


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source