【问题标题】:How to NOT refresh backgroundQuery vba如何不刷新 backgroundQuery vba
【发布时间】:2013-10-10 08:27:43
【问题描述】:

有谁知道如何停止刷新查询表不断刷新,只刷新一次。他不断刷新,使我的 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

【问题讨论】:

    标签: vba excel web refresh


    【解决方案1】:

    改变这一行:

    .BackgroundQuery = True
    

    到:

    .BackgroundQuery = False
    

    【讨论】:

    • 糟糕。我绝对误读了这个问题:) +1 以获得最佳答案。我的会有用,但不会这样做。
    • @enderland,当这种情况发生时我讨厌它:)。但至少我们有两个笑脸头像。
    【解决方案2】:

    使用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

    【讨论】:

      猜你喜欢
      • 2013-11-23
      • 2015-01-26
      • 2010-10-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-15
      相关资源
      最近更新 更多