Adriuana,
What is cn in this code?
This works fine for me
Dim oRS As Object
Dim sConnect As String
Dim sSQL As String
Dim sFile As String
Dim oOrig As Worksheet
Dim osh As Worksheet
Dim oCell As Range
Dim aryData
sFile = "C:\myTest\Volker1.xls"
' Query based on the worksheet name.
sSQL = "SELECT * FROM [Sheet1$]"
Set oRS = CreateObject("ADODB.Recordset")
oRS.Open sSQL, sConnect, 0, 1, 1
If Not oRS.EOF Then
aryData = oRS.getrows()
Else
MsgBox "No records returned.", vbCritical
End If
MsgBox "Cell A2 contains " & aryData(0, 0)
MsgBox "Cell D4 contains " & aryData(3, 2)
' Clean up our Recordset object.
oRS.Close
Set oRS = Nothing
--
HTH
Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
"Adriana Camargo" wrote in message
...
I copied the data into a new file, and then it works fine.
Im using some others files that work fine.
The error ocurr just when the program tries to open the connection to
the file.
If somebody can give me a hint?
This is the code that i used to open the excel file.
strExcelConnectionString =
"Provider=Microsoft.Jet.OLEDB.4.0;data source=" & strFileName &
";Extended Properties=""Excel 8.0;HDR=No;IMEX=1"""
cn.ConnectionString = strExcelConnectionString
cn.Open
Thanks!!!
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!