ExecuteExcel4Macro to get value from closed workbook

It depends on how you use it. The open file dialog box is being showed to you because the “strPath” doesn’t have a “” in the end 😉

Try this code.

Option Explicit

Sub Sample()
    Dim wbPath As String, wbName As String
    Dim wsName As String, cellRef As String
    Dim Ret As String
    
    'wbPath = "C:\Documents and Settings\Siddharth Rout\Desktop\"
    wbPath = "C:\Users\my.name\Desktop\"
    
    wbName = "QOS DGL stuff.xls"
    wsName = "ACL"
    cellRef = "C3"
    
    Ret = "'" & wbPath & "[" & wbName & "]" & _
          wsName & "'!" & Range(cellRef).Address(True, True, -4150)
    
    MsgBox ExecuteExcel4Macro(Ret)
End Sub

Leave a Comment