How to retrieve data from access database(.accdb) into excel using vba
<p>I'm working on Excel VBA macros and I want to retrieve data from a MS Access database (<code>.accdb</code> file).</p>

<p>I've tried using below connection string and it throws runtime error '438'</p>

<pre><code>   Dim cn As Object, rs As Object,DBFullName As String,Target As Range
   DBFullName = "D:\Tool_Database\Tool_Database.accdb"
   Set Target = Sheets("Sheet1").Range("A1")
   Set cn = CreateObject("ADODB.Connection")
   cn.Open "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" &amp; DBFullName &amp; ";"

   Set rs = CreateObject("ADODB.Recordset")
   rs.Open "SELECT * FROM test", cn, , , adCmdText

  For int i = 0 To rs.Fields.Count - 1
  Target.Offset(1, i).Value = rs.Fields(i).Name
  Next
  Target.Offset(1, 0).CopyFromRecordset rs
  rs.Close
  Set rs = Nothing
  cn.Close
  Set cn = Nothing
</code></pre>

<p>PLease help me to resolve the error</p>