title: Auto refresh pivot tables VBA code
body: <p>I am responsible for updating an Excel spreadsheet which pulls its information from an Access database on a daily basis. All the data that i need for my excel spreadsheet is available for me and all that i need to do is click the refresh button.</p>
  
  <p>I've sourced a VBA code which serves my purposes for small documents, however, when i open the larger files it doesn't work correctly.  The code opens the workbook specified but does not run its refresh step - it simply saves and closes the document.  I tried to put in time delays to allow time for the refresh but it seems the refresh never actually starts on the bigger files.   </p>
  
  <p>Any ideas?  The code i am using is as follows</p>
  
  <pre><code>Sub Autorefresh()
  
  Dim Excel
  Set Excel = CreateObject("Excel.Application")
  
  Excel.Visible = True
  Excel.DisplayAlerts = False
  Excel.AskToUpdateLinks = False
  Excel.AlertBeforeOverwriting = False
  
  Set Workbook = Excel.Workbooks.Open("MyWorkbook.xlsx", Password:="MyPassword")
  Workbook.RefreshAll
  Workbook.Save
  
  Excel.Quit
  Set Workbook = Nothing
  Set Excel = Nothing
  
  End Sub
  </code></pre>