Dost možná i takhle: http://spreadsheetpage.com/index.php/sit...
Dim aVal = GetValue("C:\Documents and Settings\Dokumenty", "Soubor.xls", "List1", "D3")
Private Function GetValue(ByVal path, ByVal file, ByVal sheet, ByVal ref)
Dim xl As Object
xl = CreateObject("Excel.Application")
' Retrieves a value from a closed workbook
Dim arg As String
' Make sure the file exists
If Microsoft.VisualBasic.Strings.Right(path, 1) <> "\" Then path = path & "\"
If Dir(path & file) = "" Then
GetValue = "File Not Found"
Exit Function
End If
' Create the argument
Const xlA1 = 1
Const xlR1C1 = -4150
arg = "'" & path & "[" & file & "]" & sheet & "'!" & _
xl.ConvertFormula(ref, xlA1, xlR1C1, True)
' Execute an XLM macro
GetValue = xl.Application.ExecuteExcel4Macro(arg)
xl.Quit()
xl = Nothing
End Function
|