Liberteric
New Member
- Joined
- Sep 29, 2014
- Messages
- 28
I need to import the text file DPLOTUS.csv from whatever folder the workbook that contains this macro is located.
The macro below works great for me but when I give it to my fiance, the folder names will be different. What won't be different is the workbook AND the text file will be located in the same folder.
Sub Import()
'
' import Macro
'
'
Sheets("TB").Select
Columns("A:D").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("A9").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Users\cbeaulieu\Desktop\DPLOTUS.csv", Destination:=Range("$B$9"))
.Name = "DPLOTUS"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 9, 1, 9, 9, 9, 9)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
The macro below works great for me but when I give it to my fiance, the folder names will be different. What won't be different is the workbook AND the text file will be located in the same folder.
Sub Import()
'
' import Macro
'
'
Sheets("TB").Select
Columns("A:D").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("A9").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Users\cbeaulieu\Desktop\DPLOTUS.csv", Destination:=Range("$B$9"))
.Name = "DPLOTUS"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 9, 1, 9, 9, 9, 9)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With