Hi all,
Can you please assist. I currently got a macro that imports data (.dat), however i can only get it to pick it up from a specified location. The requirement is to make it pick up the files (they are always the same) from the same location that the spreadsheet is in. So pretty much fileName = ActiveWorkbook.Path + "<file name>". However, i can not get it to work. Can someoine please help me make the path the active workbook path. Thanks.
My current code is.
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Test\<test file.dat>", Destination:=Range("A1"))
.Name = "<name>"
.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 = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1)
.TextFileFixedColumnWidths = Array(1, 9, 50, 50, 50, 15, 37)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
Bookmarks