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() )

Sub Auto_Open()
Application.DisplayAlerts = False
    ChDir "T:\EXPLOIT\TSMENV\EXCEL\politiques"
    Workbooks.Open Filename:="t:\EXPLOIT\TSMENV\EXCEL\politiques\politiques.xls", _
        UpdateLinks:=3
    For i = 1 To ActiveWorkbook.PivotCaches.Count
        ActiveWorkbook.PivotCaches(i).RefreshOnFileOpen = False
    Next
    For i = 1 To ActiveWorkbook.Sheets.Count
        For j = 1 To ActiveWorkbook.Sheets(i).QueryTables.Count
            ActiveWorkbook.Sheets(i).QueryTables(j).RefreshOnFileOpen = False
        Next
    Next
    ActiveWorkbook.RefreshAll
    ActiveWorkbook.RefreshAll
    ActiveWorkbook.RefreshAll
    ActiveWorkbook.Save
    ActiveWindow.Close
    Application.Quit
End Sub
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS