UPD: Excel-based version instead of VBScript is here.
I know what you think.
Yet another solution to refresh Excel files with connections and Data Model (aka PowerPivot).
Plenty of them can be found on the Internet. Different programming languages, different level of complexity
- Excel and PowerPivot refresh suite: https://excelrefresher.codeplex.com/
And, of course – Power Update
Year ago, when I decided to write my own refreshing program, Power Update was already on market, however, I couldn’t get it for myself, due to some reasons. In addition, I wanted to slightly adjust a process of refreshing and saving.
Since there is a lot of “power” around Excel last years, I had no choice and called my script “Power Refresh”.
Shortly about Power Refresh,
- it is available on GitHub
- It is developed by usual analyst (grown on Excel), non-professional programmer
It consists of mix of Visual Basic Script and VBA. VBS file contains main code.
VBS embeds VBA into Excel VB project, and actually VBA launches RefreshAll. I went such way to have more control on Excel side during refresh to handle errors, and avoid problem when VBS waits for OLE-application too long then raise exceptions.
VBS and VBA are selected due to
- requirement: user doesn’t need anything but workstation with Windows and MS Office installed (32 or 64 bit) to automate Excel-based reporting
- fact that any advanced Excel-analyst can understand code and adjust it for own needs
- User doesn’t need administrator rights (meaningful for corporate world)
- No need to install any IDE (like Visual Studio), Notepad++ is enough
- VBS can be scheduled using Windows Task Scheduler
- It is a bit outdated (at the moment of writing this post)
As any other software, it requires support and development. This is why better to think twice about Power Update. Support and development are done by professional programmers and included into price.
However, not in case of my “temporary” solution.
Now, I hope to find time to touch Power Refresh code again.
Some changes I plan
introduce named arguments and use switches when call VBS
probably, switch for detailed log / short log / no log
Probably, integration with SAP BO Analysis automation
Run macro before / after – as switches
Short listing of ideas below.
‘ R-eport or T-ransfer
‘ Report: ThisWorkbook.RefreshAll will be used and then entire file will be saved as separate file
‘ Transfer: expected sheet Result, which will be saved as a new workbook
‘ PQ query with load to sheet Result (limited by rows on sheet)
‘ Optional switches
‘ If omitted: script uses default path
‘ script will add datetime to resulting file name. Work for both R and T. Meaningful for data transfer.
‘ each value will be entered into named range SCOPE. File will be refreshed for that Scope
‘ * use quotes for arguments that contain spaces
‘ if argument is omitted file will be refreshed
‘ for T – using default Scope (do not requre SCOPE named range in workbook)
‘ for R – list of scopes will be collected from Scopes table
‘ if argument is omitted file will be saved in the same folder as initial workbook
‘ For T – extension of resulting file is always xlsx
‘ For R – xlsx or xlsm (xlsb -> xlsm) (as some applications cannot consume xlsb)
‘ Excel application will be visible and ScreenUpdating turned On
‘ always DisplayAlerts = False
‘ recipients of emails on errors
‘ script will write log if argument provided
‘ If omitted default path will be used.
‘ Default path variable –