Import data from Access 2007

J

Johnnie

I need to link data from Access 2007 into my Excel 2007 worksheet. That
seems simple enough, but I don't want to include the column headers from the
Access database. Is there a way to link to the data and NOT bring in the
column headers? Thanks! Johnnie
 
J

Jacob Skaria

Hi Johnnie

Try out the below method using ADODB.

Sub ExtractFromAccess()
Dim strDB As String, lngRow As Long
Dim con As New ADODB.Connection, rs As New ADODB.Recordset

strDB = "C:\opstats.mdb"
con.Open "DBQ=" & strDB & ";Driver={Microsoft Access Driver (*.mdb)}"
rs.CursorLocation = adUseClient
rs.Open "select * from opmast", con, adOpenDynamic
'---------------------------------
lngRow = 1
Do While rs.EOF = False
Range("A" & lngRow) = rs("opid")
Range("B" & lngRow) = rs("opname")
lngRow = lngRow + 1
rs.MoveNext
Loop
'---------------------------------
rs.Close: con.Close
Set rs = Nothing: Set con = Nothing
End Sub

If this post helps click Yes
 

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