我想在Excel中使用宏导入最后修改的txt文件。 我有一个每天增加一个新的txt文件的文件夹。 目标是导入添加到目录中的最后一个txt文件。使用Excel导入txt与宏?
我已经创建了一个Excel文件,其中包含一个受宏影响的按钮。
下面是宏的代码:
Sub Import()
'
' Import Macro
' Macro saved on 02/03/2011 by StYellowknife3000
'
'
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Folder\File_01.txt", Destination:= _
Range("A1"))
.Name = "File_01"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 932
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = True
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = True
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
End Sub
谢谢