Why does PQ refer to previous workbook

JeffGrant

Well-known Member
Joined
Apr 7, 2021
Messages
558
Office Version
  1. 365
Platform
  1. Windows
Hi All,

for some time now, I have noticed that with my XLSM workbooks that have PQ's in them, when I do a SAVE AS and change the workbook name, I don't understand why some of the PQ's in the new workbook refer back to the previous workbook as external queries.

Then I get get the usual External Query warning with Enable / Disable options when opening the new workbook.

Can somebody please tell me...

1. Why does excel do this?
2. Is there a fix so that I dont have to rebuild the PQ's that are giving the external refernce warning?

Really hoping I am doing something wrong and that this can be fixed quickly.

Thanks for your help in advance.

Jeff
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Perhaps you created the query using the Get Data - From File - From Excel workbook function? I can't think of any other reason it would store a path.
 
Upvote 0
Hi Rory,

you are indeed correct. There is an opening PQ that uses an external path being:
Excel.CurrentWorkBook(){[Name="FilePath"]}[Conent]{0}[Column1]
then: the Path.
Then: the file name
Then: = Csv.Document(File.Contents(FilePath & FileName),[Delimiter=",", Columns=65, Encoding=1252, QuoteStyle=QuoteStyle.None])

However, I dont see any reference to the workbook name other than Excel.CurrentWorkBook().

So if the file is called test1.xlsm, then I do a SAVE As Test2.xlsm, surely the term CurrentWorkBook statement should now look at Test2.xlsm.

But for some reason, it is still refering to Test1.xlsm??????

Am I missing something

Any Ideas?

Ps this, this is not new, it has been happening sinse I started this project. I just never sort out a solution.

chat soon.
 
Upvote 0
There isn't anything there that could refer to another workbook, unless the named range "Filepath" has an external reference in it.

Out of curiosity, what makes you say it's referring to the old workbook?
 
Upvote 0
Because when I run the macro, it opens the previous version. :( of teh workbook and I get the MS warning message about external refereces Enable/Disable...
 
Upvote 0
ahhhh, I worked it out.

I keep forgetting that when I do a SAVE AS, that the custom tools bars need to be reset... Doh!
 
Upvote 0
Solution

Forum statistics

Threads
1,223,632
Messages
6,173,467
Members
452,516
Latest member
archcalx

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