Using ADO to read from ActiveWorkbook

G

Gabriel Carulias

Hi all

I have an Excel file and I am reading data from the ActiveWorkbook. I am
using the below code to create a ADODB connection.

Dim dt As New ADODB.Connection

With dt
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source=" & ThisWorkbook.Path & "\" &
ThisWorkbook.Name
.Properties("Extended Properties") = "Excel 8.0;HDR=Yes"
.Open
End With

The issue is that if I open firstly a blank Excel file, and then I open my
Excel file (with the above code) , when executing the “.Open†instruction,
Excel opens a new instance of my Excel file. This issue decreases the
performance of the Excel application, and provoke bad results.

How can i fix this issue? I am using an ADODB connection because I need to
run a query against Excel and then save data to a local DB.

Thank.
 

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