I am trying to use a macro to delimit a file that is created daily so it changes name all the time. The formarmat of data remains the same. So I need to choose the file location and file name then run the macro.
Here is what I have for delimiting the file:
Sub Delimit_Letter_file()
'
' Delimit_Letter_file Macro
'
'
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;X:\backupfileuploads\LTR20160226FNL3c.", Destination:=Range("$A$2"))
.CommandType = 0
.Name = "LTR20160226FNL3c."
.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 = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, _
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 _
, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
.TextFileFixedColumnWidths = Array(8, 9, 9, 10, 20, 20, 20, 25, 25, 25, 25, 25, 25, 25, _
25, 25, 25, 15, 15, 15, 20, 20, 8, 10, 20, 40, 40, 20, 8, 8, 19, 30, 35, 35, 35, 13, 12, 5, 48, 20, 20, 15 _
, 5, 9, 5, 4, 4, 5, 9, 5, 20, 20, 20, 20, 15, 15, 15, 15, 15, 15, 50, 6, 25, 25, 10, 1, 6, 20, 10, 30, 1, 10, _
1, 1, 8, 11)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub
Here is what I have for delimiting the file:
Sub Delimit_Letter_file()
'
' Delimit_Letter_file Macro
'
'
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;X:\backupfileuploads\LTR20160226FNL3c.", Destination:=Range("$A$2"))
.CommandType = 0
.Name = "LTR20160226FNL3c."
.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 = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, _
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 _
, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
.TextFileFixedColumnWidths = Array(8, 9, 9, 10, 20, 20, 20, 25, 25, 25, 25, 25, 25, 25, _
25, 25, 25, 15, 15, 15, 20, 20, 8, 10, 20, 40, 40, 20, 8, 8, 19, 30, 35, 35, 35, 13, 12, 5, 48, 20, 20, 15 _
, 5, 9, 5, 4, 4, 5, 9, 5, 20, 20, 20, 20, 15, 15, 15, 15, 15, 15, 50, 6, 25, 25, 10, 1, 6, 20, 10, 30, 1, 10, _
1, 1, 8, 11)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub