Refresh BackgroundQuery:=False | help needed?

淺唱寂寞╮ 提交于 2019-12-24 12:41:06

问题


I've looked at some others with the same error but their solution doesn't help me.

Refresh BackgroundQuery:=False Error 1004

Here is my code

'
' 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:


Try the below line

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

or

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


来源:https://stackoverflow.com/questions/33428059/refresh-backgroundquery-false-help-needed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!