Connecting to another excel workbook

dgrimm

Board Regular
Joined
Sep 17, 2007
Messages
159
I am trying to automate updates in a workbook that I am creating by pulling a table from another workbook.

I was given the following code to start with:

Sub EXCEL_DATA_GRAB()

Dim cnt As ADODB.Connection
Dim rst As ADODB.Recordset
Dim rstKey As ADODB.Recordset
Dim strQry As String
Dim strQryKey As String

' Dim rngPop As Variant
'
' Set rngPop = ThisWorkbook.Sheets("GetData").Range("_Population")

'//Build connection string
strConProvider = "Provider=Microsoft.ACE.OLEDB.12.0;"
strConSource = "Data Source=" & " J:\STOP LOSS\jpo\ultimatePA\" & Sheet4!A6 & "\" & Sheet4!A6 & "-" & Z6 & "\SNAP_SHOT-" & Sheet4!A6 & "-" & Sheet4!B6 & "-" & Sheet4!C6 & ".xlsm;" strConExtProp = "Extended Properties=Excel 12.0;"
strConSecurity = "Persist Security Info=False"
strCon = strConProvider & strConSource & strConExtProp & strConSecurity


End Sub

But when I look at the connection detail from manually connecting the two I get a lot more information:

Provider=Microsoft.ACE.OLEDB.12.0;
User ID = Admin
Data Source=J:\STOP LOSS\jpo\ultimatePA\2011\2011-03\SNAP_SHOT-2011-MAR-31.xlsm;
Mode=Share Deny Write;
Extended Properties="HDR=YES;";
Jet OLEDB:System database="";
Jet OLEDB:Registry Path="";
Jet OLEDB:Engine Type=37;
Jet OLEDB:Database Locking Mode=0;
Jet OLEDB:Global Partial Bulk Ops=2;
Jet OLEDB:Global Bulk Transactions=1;
Jet OLEDB:New Database Password="";
Jet OLEDB:Create System Database=False;
Jet OLEDB:Encrypt Database=False;
Jet OLEDB: Dont Copy Locale on Compact=False;
Jet OLEDB:Compact Without Replica Repair=False;
Jet OLEDB:SFP=False;
Jet OLEDB:Support Complex Data=False

The data source in the manual connection has not been edited for the variables. That is why it looks different. What I am doing is having the user select the date from 3 validation drop downs to form the needed date for the data pull.

I am lost at what information I need from the manual connection that I located in order for it to work in vba. I am pulling the information from lets say DataSheet.

Any help would be greatly appreciated.

Thank you

Dave
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

Forum statistics

Threads
1,224,537
Messages
6,179,408
Members
452,912
Latest member
alicemil

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top