Refresh links in excel stay open long enough to complete then save

I have a vb script that runs on a schedule.
It is supposed to open an excel file and refresh the links then save the file.
The problem it is that the  links take a few seconds to refresh and the file closes before it is done refreshing so i end up with a bunch of #NA where the data should be




Dim xlApp, vFile
 vFile = "C:\your file.xls"
 Set xlApp = CreateObject("excel.application")
 With xlApp.Workbooks.Open(vFile, True)
  .Close True
 End With
 xlApp.Quit
 Set xlApp = Nothing
mcgilljdAsked:
Who is Participating?
 
Jorge PaulinoIT Pro/DeveloperCommented:
Have you gived any time to update the links ?

 With xlApp.Workbooks.Open(vFile, True)
   System.Threading.Thread.Sleep(200)
   Application.DoEvents
  .Close True
 End With
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.