P
PEGWINN
Hi there folks. I have a macro that will import .txt files into excel03. I
recorded it using the "record macro" feature. So, the original text file is
in the macro code.
Sub DirectoryClean()
'
' DirectoryClean Macro
' Macro recorded 6/12/2008 by PE GWINN
'
' Keyboard Shortcut: Ctrl+g
'
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Documents and
Settings\Phil\Desktop\directory\directory.txt", _
Destination:=Range("A1"))
.Name = "aerobics"
.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)
.TextFileFixedColumnWidths = Array(10, 7, 4, 9, 9)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub
What I want to do is have the macro loop in that directory and import each
text file into a new worksheet tab. I have an answer on the tip of my tongue
but it just wont gel.
Thanks a lot.
Phil
recorded it using the "record macro" feature. So, the original text file is
in the macro code.
Sub DirectoryClean()
'
' DirectoryClean Macro
' Macro recorded 6/12/2008 by PE GWINN
'
' Keyboard Shortcut: Ctrl+g
'
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Documents and
Settings\Phil\Desktop\directory\directory.txt", _
Destination:=Range("A1"))
.Name = "aerobics"
.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)
.TextFileFixedColumnWidths = Array(10, 7, 4, 9, 9)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub
What I want to do is have the macro loop in that directory and import each
text file into a new worksheet tab. I have an answer on the tip of my tongue
but it just wont gel.
Thanks a lot.
Phil