如何不刷新backgroundQuery vba

有谁知道如何停止刷新查询表不断刷新,只刷新一次。 他不断刷新,正在让我的Excel电子表格运行缓慢。

With ActiveSheet.QueryTables.Add(Connection:= _ "URL;" & FilePath, _ Destination:=temp.Range("A1")) .Name = "Deloitte_2013_08" ' .CommandType = 0 .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .BackgroundQuery = True .RefreshStyle = xlInsertDeleteCells .SavePassword = False .SaveData = True .AdjustColumnWidth = True .RefreshPeriod = 0 .WebSelectionType = xlEntirePage .WebFormatting = xlWebFormattingNone .WebPreFormattedTextToColumns = True .WebConsecutiveDelimitersAsOne = True .WebSingleBlockTextImport = False .WebDisableDateRecognition = False .WebDisableRedirections = False .Refresh BackgroundQuery:=False End With 

改变这一行:

 .BackgroundQuery = True 

至:

 .BackgroundQuery = False 

使用Application.ScreenUpdating包装您的代码。

 application.screenupdating = false With ActiveSheet.QueryTables.Add(Connection:= _ "URL;" & FilePath, _ Destination:=temp.Range("A1")) .Name = "Deloitte_2013_08" ' .CommandType = 0 .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .BackgroundQuery = True .RefreshStyle = xlInsertDeleteCells .SavePassword = False .SaveData = True .AdjustColumnWidth = True .RefreshPeriod = 0 .WebSelectionType = xlEntirePage .WebFormatting = xlWebFormattingNone .WebPreFormattedTextToColumns = True .WebConsecutiveDelimitersAsOne = True .WebSingleBlockTextImport = False .WebDisableDateRecognition = False .WebDisableRedirections = False .Refresh BackgroundQuery:=False End With application.screenupdating = true 

您可能也有兴趣设置Application.Calculation xlCalculationManual大操作之前,然后将其设置为xlCalculationAutomatic完成后。