Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Sylvain Le Courtois

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

VBA procedure to pen an Excel workbook and refresh all datas in the QueryTables and PivotTable objects

// description of your code here
// Can also use the Workbook Open event ( Private Sub Workbook_Open() )

   1  
   2  Sub Auto_Open()
   3  Application.DisplayAlerts = False
   4      ChDir "T:\EXPLOIT\TSMENV\EXCEL\politiques"
   5      Workbooks.Open Filename:="t:\EXPLOIT\TSMENV\EXCEL\politiques\politiques.xls", _
   6          UpdateLinks:=3
   7      For i = 1 To ActiveWorkbook.PivotCaches.Count
   8          ActiveWorkbook.PivotCaches(i).RefreshOnFileOpen = False
   9      Next
  10      For i = 1 To ActiveWorkbook.Sheets.Count
  11          For j = 1 To ActiveWorkbook.Sheets(i).QueryTables.Count
  12              ActiveWorkbook.Sheets(i).QueryTables(j).RefreshOnFileOpen = False
  13          Next
  14      Next
  15      ActiveWorkbook.RefreshAll
  16      ActiveWorkbook.RefreshAll
  17      ActiveWorkbook.RefreshAll
  18      ActiveWorkbook.Save
  19      ActiveWindow.Close
  20      Application.Quit
  21  End Sub
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS