美好的早晨! 我有一个电子表格,在365上创建了电子表格,但是一些需要使用它的用户有Excel 2010 我有一些需要单独更新的连接,我无法使用Refreshall。 在...

问题描述 投票:0回答:0

SpreadsheetOrigem.ListObjects("OCs").Refresh SpreadsheetOrigem.ListObjects("Stock").Refresh SpreadsheetOrigem.ListObjects("Demands").Refresh

但在Excel 2010中,此代码不起作用。 我尝试了:

ActiveWorkbook.Connections("OCs").Refresh ActiveWorkbook.Connections("Stock").Refresh ActiveWorkbook.Connections("Demands").Refresh

奇怪的是,第一个连接正常更新,但其他连接不会更新。
似乎更新是在“未决”,不接受其他人。
即使背景关闭了。
我感谢任何帮助。

help in VBA在各种版本中工作。

您可以在下面尝试致电。没有参数,它将刷新WB中的所有连接。如果您给出辩论,请确保您具有确切的连接名称。如果您想重新添加BCKGR刷新,则无需bckgr语句即将结束。 最后,MSGBX是可选的,因此您可以将其删除或根据需要量身定制。

Sub Refresh_All_Data_Connections(Optional TableToRefresh As String) On Error GoTo ErrorHandler Dim TableToRefresh As String Dim objConnection, bBackground For Each objConnection In ThisWorkbook.Connections 'Get current background-refresh value bBackground = objConnection.OLEDBConnection.BackgroundQuery 'Temporarily disable background-refresh objConnection.OLEDBConnection.BackgroundQuery = False If TableToRefresh = "" Then 'Refresh All connections objConnection.Refresh ElseIf TableToRefresh = objConnection Then 'Refresh specific connection objConnection.Refresh End If 'Set background-refresh value back to original value ' objConnection.OLEDBConnection.BackgroundQuery = bBackground Next Exit Sub ErrorHandler: Debug.Print objConnection.Name If objConnection.Name <> "ThisWorkbookDataModel" Then MsgBox "The query: " & objConnection.Name & " could not refresh. Did you save the response Excel's in the response folder?", vbCritical End End If End Sub
    

excel vba excel-2010
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.