View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Spike Spike is offline
external usenet poster
 
Posts: 140
Default Copy data without opening file and without using ADO

Thanks for your example code i am having trouble making it run. I am running
Excel 2003, i have set Tools/Refs to Microsoft DAO 3.51 Object Library and
get an error message "Run Time Error 429. ActiveX Component can't create
object"

I have adapted your code as below and it bombs out on the line "Set db=
OpenDatabase etc

Function QuerySheet()
Dim db As DAO.Database, rst As DAO.Recordset, Source As String

Source = "H:\Cash Recs\NetAssets.xls"

Set db = OpenDatabase(Source, dbDriverNoPrompt, False, "Excel 8.0")
Set rst = db.OpenRecordset("Assets")

With rst
'Do Something
End With

Set rst = Nothing
Set db = Nothing
End Function

However i word it using other code i get an error where the db is empty
--
with kind regards

Spike


"Dave Miller" wrote:

Here is a sample function:

Regards,

David Miller

Function QuerySheet()
Dim db as DAO.Database, _
rst as DAO.Recordset, _
Source as string

Source = "C:\FileName.xls"
Set db = OpenDatabase(Source, _
dbDriverNoPrompt, _
False, _
"Excel 8.0")
Set rst = db.OpenRecordset("Named Range Here")

with rst
'Do Something
end with

Set rst = Nothing
Set db = Nothing
End Function