View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
tony h[_25_] tony h[_25_] is offline
external usenet poster
 
Posts: 1
Default Open mdb file from another computer


This code opens the database gets the data and pastes it onto the
spreadsheet. It is referencing the Microsoft DAO 3.6 Object Library
although others will work and you may prefer to use ActiveX Data
Objects.

Sub a()
Dim db As DAO.Database
Dim rst As Recordset

Dim strSQL As String

Dim rng As Range

Set db = DAO.OpenDatabase("C:\_pms\dbforum.mdb")

strSQL = "select CLNAM1,CLNAM2 from _client where CLSORC<"""";"
Set rst = db.OpenRecordset(strSQL)

Set rng = ThisWorkbook.Worksheets(1).Range("A1")
rng.CopyFromRecordset rst

Set rst = Nothing
db.Close
Set db = Nothing
MsgBox "done : " & strSQL
End Sub


--
tony h
------------------------------------------------------------------------
tony h's Profile: http://www.excelforum.com/member.php...o&userid=21074
View this thread: http://www.excelforum.com/showthread...hreadid=502862