0 votes
in VBA by Beginner (5 points)

Hi

I am trying to automatically open a excel power query file and refresh on a schedule basis however the above prompt keeps on popping up -  "This will cancel a pending refresh".

Is it the Dim pause or do I perhaps need to disable notifications?

See query below:
 

Set fso = CreateObject("Scripting.FileSystemObject")
Set xl  = CreateObject("Excel.Application")
xl.Visible = True

For Each f In fso.GetFolder("C:\Users\BenjaminS\Google Drive\appsheet").Files
  If LCase(fso.GetExtensionName(f.Name)) = "xlsx" Then
    Set wb = xl.Workbooks.Open(f.Path)
    wb.RefreshAll
 Dim Pause
Pause = DateAdd("s",50, Now())

    wb.Save
    wb.Close
  End If
Next

xl.Quit

 

1 Answer

+1 vote
by Skilled (605 points)
selected by
 
Best answer

Try these lines

xl.Visible = True
xl.DisplayAlerts = False
'Code
xl.DisplayAlerts = True

 

by Beginner (5 points)
Working, thank you very much. :)
by Skilled (605 points)
You're welcome. Glad it worked for you

Welcome to wellsr Q&A
wellsr Q&A is the VBA and Python programming community that rewards you for learning how to code.

Getting Started
Register
VBA Cheat Sheets (On Sale Now)

Earn free prizes for asking VBA and Python questions and for answering questions asked by others in our community.

What makes us different?
Our points system rewards you with a chance for free gifts based on the quality of your questions and answers. All you have to do is post and you could get rewarded, like these members:

runfunke $10 Amazon Gift Card
coolag $10 Amazon Gift Card
Siew Hun $10 Amazon Gift Card

So, why don't you join us? It really is an encouraging way to motivate members in our VBA and Python community.

Register

For more programming tips visit the VBA Tutorials Blog and the Python Tutorials Blog.

...