我想在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
謝謝