Get value from a closed workbook

Excel does not have a built-in function to get value from a closed workbook. Below function achieves this using ExecuteExcel4Macro and some reworking of the procedure arguments to fill the argument String.


Public Function GetValueFromClosedWorkbook(FileName As String, Sheet As String, CellAddress As String)
'?GetValueFromClosedWorkbook("C:\temp\excel partners.xlsx", "Excel", "B2")
Dim strFilePath As String, strFileNameShort As String, strArg As String
    strFilePath = Left(FileName, InStrRev(FileName, "\"))
    strFileNameShort = Right(FileName, Len(FileName) - InStrRev(FileName, "\"))
    strArg = "'" & strFilePath & "[" & strFileNameShort & "]" & Sheet & "'!" & _
          Range(CellAddress).Range("A1").Address(, , xlR1C1)
    GetValueFromClosedWorkbook = ExecuteExcel4Macro(strArg)
End Function