刷新BackgroundQuery:= False |需要帮助?

时间:2015-10-30 03:13:58

标签: excel vba excel-vba database-connection

我看了其他一些有同样错误的人,但他们的解决方案对我没有帮助。

  

Refresh BackgroundQuery:=False错误1004

这是我的代码

'
' LoadData Macro
'

'
With ActiveSheet.QueryTables.Add(Connection:= _
    "TEXT;Macintosh HD:Users:Karrar:Desktop:Excel.txt", Destination:=Range("A1"))
    .Name = "Excel"
    .FieldNames = True
    .RowNumbers = False
    .FillAdjacentFormulas = False
    .RefreshOnFileOpen = False
    .BackgroundQuery = False
    .RefreshStyle = xlInsertDeleteCells
    .SavePassword = False
    .SaveData = True
    .AdjustColumnWidth = False
    .TextFilePromptOnRefresh = False
    .TextFilePlatform = xlMacintosh
    .TextFileStartRow = 1
    .TextFileParseType = xlDelimited
    .TextFileTextQualifier = xlTextQualifierDoubleQuote
    .TextFileConsecutiveDelimiter = True
    .TextFileTabDelimiter = False
    .TextFileSemicolonDelimiter = False
    .TextFileCommaDelimiter = False
    .TextFileSpaceDelimiter = True
    .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
    .UseListObject = False
    .Refresh BackgroundQuery:=False
End With
End Sub

1 个答案:

答案 0 :(得分:1)

尝试以下行

ActiveSheet.Range("A1").QueryTables(1).Refresh BackgroundQuery:=False

ActiveSheet.QueryTables(1).Refresh BackgroundQuery:=False