Option Explicit
Public cnn As Object
Public rs As Object
Public strSQL As String
Sub OpenDB()
Set cnn = CreateObject("ADODB.Connection")
cnn.connectionstring = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:UsersveekayDocumentsNorthwind.accdb;Persist Security Info=False"
cnn.Open
End Sub
Sub getData()
OpenDB
Set rs = CreateObject("ADODB.Recordset")
rs.cursorlocation = 3 'Client
strSQL = "Select * from products"
rs.Open strSQL, cnn
If rs.RecordCount > 0 Then
Do While Not rs.EOF
ActiveCell.CopyFromRecordset rs
Loop
Else
End If
Set rs = Nothing
End Sub