Good day,
Question:
Using ADO (via VBA), is it possible for one single SQL query to simultaneously connect to both an Excel file and a .txt file? I would then do a UNION ALL operation to merge both sets of data.
Additional details:
I use ADO (via VBA) to connect to an Excel file as follow.
It works quite fine to connect to two or more Excel files with the same query by using an SQL string such as:
SELECT * FROM [Sheet1$] UNION SELECT * FROM [Sheet1$] IN 'C:\ADOTest.xls' 'Excel 8.0;'
Excerpt only
Thank you!
Louis
Question:
Using ADO (via VBA), is it possible for one single SQL query to simultaneously connect to both an Excel file and a .txt file? I would then do a UNION ALL operation to merge both sets of data.
Additional details:
I use ADO (via VBA) to connect to an Excel file as follow.
It works quite fine to connect to two or more Excel files with the same query by using an SQL string such as:
SELECT * FROM [Sheet1$] UNION SELECT * FROM [Sheet1$] IN 'C:\ADOTest.xls' 'Excel 8.0;'
Excerpt only
Code:
MainSourceFile = ActiveWorkbook.Path & "\" & ActiveWorkbook.Name
szConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & MainSourceFile & ";" & _
"Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"";"
szSQL = Range("SQLcommand").Value2
Set rsCon = CreateObject("ADODB.Connection")
Set rsData = CreateObject("ADODB.Recordset")
rsCon.Open szConnect
rsData.Open szSQL, rsCon, adCmdText
Thank you!
Louis