The following VBA code is part of a macro that pulls data in from a CSV file. It works fine on a number of PCs that run Excel 2007 and 2010, but fails with the following error on PCs running Excel 2013.
'Run-time error 1004: Application-defined or Object-defined error'
The error occurs at the following line
.Refresh BackgroundQuery:=False
If I comment out this line, I don't get an error, but I don't get the data imported either.
Any help would be gratefully accepted.
With ActiveSheet.QueryTables.Add(Connection:=connectionName, Destination:=Range("$A$1"))
.Name = "por800.csv"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 850
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, _
1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With