所以这是我在Excel中的子程序:
Sub refreshAll()
Dim con As String
Dim percent As String
Dim cLen As Integer
Dim i As Integer
Dim total As Integer
Dim pInt As Double
cLen = ActiveWorkbook.Connections.count
total = cLen - 1
For i = 0 To total
con = "Connection" & i
pInt = i / cLen
percent = FormatPercent(pInt, 0)
ActiveWorkbook.Connections(con).Refresh
Application.StatusBar = "Updated " & i & " of " & cLen & " | " & percent & " Complete"
Next i
Application.StatusBar = "Update Finished"
End Sub
在Excel 2010中,这非常有效,但在Excel 2013中,它所做的只是压缩所有连接而不实际刷新它们。连接被禁用后台刷新,我已经确认2010确实有效,但2013年没有。有谁知道ActiveWorkbook.Connections(x).Refresh是否在2013年不起作用?也许有一个我可能错过的设置?
答案 0 :(得分:0)
根据this MSDN nugget,尝试这个远景:
ActiveWookbook.Connections(con).Refresh(False)
根据链接的文章,False
应该等到获取数据之后。但是,正如我所说,这可能是一个远景。