VBA pathway specification for a data connection between two excel files

ANDYB0ARDMAN

New Member
Joined
Jun 23, 2019
Messages
5
All - good evening

Having some issues getting vba to work that specifically points two different data query table connections in one file to a specific separate source file.

The specific source file is located in c:\Crop Chemical Database\Crop Chemical Database.xlsm
I want the receiving (destination) spreadsheet to update two tables on open - one in a worksheet tab called "Table-Data" and one in tab called "Table-Setup". I have set up an auto_open command but as the destination sheet can be saved by others in various locations I need to be really specific about the source file location in the vba so no matter where they save the destination file the vba makes the connections look for the source file.
The two querys are named "Data 13" in Table-Data tab and "Setup" in Table-Setup tab
I have tried this for first table

With Worksheets("Table-Data").QueryTables(1)
.Connection = "XML;C:\Crop Chemical Database\Crop Chemical Database.xlsm"
.refresh BackgroundQuery:=False
End With

Not working for me....

Need to get this working so would appreciate any help you can provide.

thanks.............Andy
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Forum statistics

Threads
1,215,036
Messages
6,122,794
Members
449,095
Latest member
m_smith_solihull

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