This code is from an edited macro & is designed to import a text file which is stored automatically with a date based name
"Ext" reffers to pre defined file extention string, and the FileName string is made up of information from cells in the spreadsheet. I have tested this string and it is producing the correct filename (I think!).
The code will not function and I can't figure out why. When I debug, it highlights the final line " .Refresh BackgroundQuery:=False". Any fix or alternate code sugestions would be very welcome.
Dim FileName As String
FileName = "TEXT;\\dd-001093-c\PressFiles\frf5600\Furnaces\Furnace" & Sheets("Control").Range("J6").Text & "\" & Sheets("Control").Range("G7").Text & Ext
Sheets("Data").Select
With ActiveSheet.QueryTables.Add(Connection:= _
FileName, _
Destination:=Range("A1"))
.Name = Sheets("Control").Range("G7")
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 850
.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)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub
Bookmarks