importing data from closed workbook

L

lieven

Hi,

I'm using below function to import data from a closed workbook :

Sub GetValuesFromAClosedWorkbook(fPath As String, _
fName As String, sName, cellRange As String)
With ActiveSheet.Range(cellRange)
.FormulaArray = "='" & fPath & "\[" & fName & "]" _
& sName & "'!" & cellRange
.Value = .Value
End With
End Sub

I am now trying to assign the result directly to a variable, but the
following fails :

myvar=application.evaluate("''c:\Myworkbook[Mysheet]'!A1:Q250")

Anyone got any ideas why , or a solution to the problem ?
 
D

Dave Peterson

You need to have the workbook open for application.evaluate() to work.
Hi,

I'm using below function to import data from a closed workbook :

Sub GetValuesFromAClosedWorkbook(fPath As String, _
fName As String, sName, cellRange As String)
With ActiveSheet.Range(cellRange)
.FormulaArray = "='" & fPath & "\[" & fName & "]" _
& sName & "'!" & cellRange
.Value = .Value
End With
End Sub

I am now trying to assign the result directly to a variable, but the
following fails :

myvar=application.evaluate("''c:\Myworkbook[Mysheet]'!A1:Q250")

Anyone got any ideas why , or a solution to the problem ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top