ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using ADO to read from ActiveWorkbook (https://www.excelbanter.com/excel-programming/375926-using-ado-read-activeworkbook.html)

Gabriel Carulias

Using ADO to read from ActiveWorkbook
 
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.


All times are GMT +1. The time now is 09:31 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com