VBA to update the Source of all Queries in a workbook?

joe1250

New member
Joined
Feb 2, 2018
Messages
14
Reaction score
0
Points
0
Excel Version(s)
2016
Hi all, I have hundreds of workbooks with power queries that i need to update the sources for as our network and server paths were recently changed. These workbooks are all essentially the same, the original workbook was set up as a template and each subsequent workbook is just a copy that has been populated with specific data, but all the queries are identical; pointing to the same folders and performing the same combine and transform functions.

I tried using the macro recorder and recording myself going into data source settings and manually renaming the paths for the data sources, but the recorder didn't capture anything.

So what I'm trying to accomplish in plain English is:

For each data source in current workbook, replace "\\myoldserver\....." with "\\mynewserver\...."

Then i can either assign a hot key so that every time i open up one of the files i can quickly update all the data sources...

Or, alternatively could I point the macro at the parent folders and create a loop that will update the data sources for every file in every subfolder, where the file name ends with *template.xlsx"?

I have spent the better part of the afternoon googling this, but so far haven't found any examples that i can use and I'm not familiar enough to be able to develop this from scratch. Any assistance would be greatly appreciated!

Thanks,
joe
 
Back
Top