sanantonio
Board Regular
- Joined
- Oct 26, 2021
- Messages
- 124
- Office Version
- 365
- Platform
- Windows
Hi All,
Me again.
I have a remote dataset linked to the functional workbook that I thought I could remotely refresh using a VBA I found somewhere on the internet (Forgive me not naming the author here I've lost it).
It works fine for things like refreshing the pivot tables etc. but it isn't refresh all the power queries. I have 4 power query data links inside the file pulling in from a variety of places. If I hit "Refresh All" in the dataset itself they pull in fine so the issue isn't with the links, it's the VBA.
Is it because this code opens, hits refresh, then closes and saves too quickly and the power queries can't pull the data quick enough? Is there a solution? I remember seeing a VBA code once that was essential to make it "Wait", not sure if that's appropriate here or if there's an alternate solution? Maybe this code is all wrong and isn't refreshing all?
Me again.
I have a remote dataset linked to the functional workbook that I thought I could remotely refresh using a VBA I found somewhere on the internet (Forgive me not naming the author here I've lost it).
VBA Code:
Public Sub refreshXLS()
Path = "K:\Users\xxx\xxxx\Dataset.xlsx" 'the workbook path you want to refresh
With Application
.DisplayAlerts = False
.ScreenUpdating = False
.EnableEvents = False
.AskToUpdateLinks = False
End With
Workbooks.Open Path
ActiveWorkbook.UpdateLink Name:=ActiveWorkbook.LinkSources
ActiveWorkbook.Close True
With Application
.DisplayAlerts = True
.ScreenUpdating = True
.EnableEvents = True
.AskToUpdateLinks = True
End With
End Sub
It works fine for things like refreshing the pivot tables etc. but it isn't refresh all the power queries. I have 4 power query data links inside the file pulling in from a variety of places. If I hit "Refresh All" in the dataset itself they pull in fine so the issue isn't with the links, it's the VBA.
Is it because this code opens, hits refresh, then closes and saves too quickly and the power queries can't pull the data quick enough? Is there a solution? I remember seeing a VBA code once that was essential to make it "Wait", not sure if that's appropriate here or if there's an alternate solution? Maybe this code is all wrong and isn't refreshing all?