So to solve an earlier issue I was having I've had to create a VBA routine to refresh my linked tables. It seems to work fine, though it is not elegant. It uses send keys to open PowerPivot window, refrehs, close it down, then wait before refreshing all charts/tables.
That last step is peculiar though -- fails the first time, but the error handling runs it again and it works fine.
Anyway thought I'd post my code here in case others find it useful or can improve upon it. I tried to use Application.ScreenUpdating = False to hide the PpowerPivot window but that causes issues.
Sub RefreshLinkedTables()
Dim i As Long
Application.SendKeys "%"
DoEvents
Application.SendKeys "G"
DoEvents
DoEvents
Application.SendKeys "Y7"
DoEvents
For i = 1 To 20000
DoEvents
Next i
Application.SendKeys "%"
DoEvents
Application.SendKeys "FC"
DoEvents
For i = 1 To 100000
DoEvents
Next i
DoEvents
On Error GoTo errHandler
ActiveWorkbook.Connections("PowerPivot Data").Refresh
DoEvents
Exit Sub
errHandler:
ActiveWorkbook.Connections("PowerPivot Data").Refresh
End Sub
That last step is peculiar though -- fails the first time, but the error handling runs it again and it works fine.
Anyway thought I'd post my code here in case others find it useful or can improve upon it. I tried to use Application.ScreenUpdating = False to hide the PpowerPivot window but that causes issues.
Sub RefreshLinkedTables()
Dim i As Long
Application.SendKeys "%"
DoEvents
Application.SendKeys "G"
DoEvents
DoEvents
Application.SendKeys "Y7"
DoEvents
For i = 1 To 20000
DoEvents
Next i
Application.SendKeys "%"
DoEvents
Application.SendKeys "FC"
DoEvents
For i = 1 To 100000
DoEvents
Next i
DoEvents
On Error GoTo errHandler
ActiveWorkbook.Connections("PowerPivot Data").Refresh
DoEvents
Exit Sub
errHandler:
ActiveWorkbook.Connections("PowerPivot Data").Refresh
End Sub