- 帖子
- 163
- 主題
- 1
- 精華
- 0
- 積分
- 170
- 點名
- 0
- 作業系統
- Window 7
- 軟體版本
- Office 2007
- 閱讀權限
- 20
- 性別
- 男
- 註冊時間
- 2010-9-5
- 最後登錄
- 2022-7-20
|
2#
發表於 2017-7-25 10:02
| 只看該作者
回復 1# sping
試試看- Sub Macro1()
- '
- ' Macro1 Macro
- ' 匯入檔案
- '
- '
- txtFile = Application.GetOpenFilename("文字檔, *.txt")
- txtFile = "TEXT;" & txtFile
- With ActiveSheet.QueryTables.Add(Connection:=txtFile, Destination:=Range("$A$2"))
- .FieldNames = True
- .RowNumbers = False
- .FillAdjacentFormulas = False
- .PreserveFormatting = True
- .RefreshOnFileOpen = False
- .RefreshStyle = xlInsertDeleteCells
- .SavePassword = False
- .SaveData = True
- .AdjustColumnWidth = True
- .RefreshPeriod = 0
- .TextFilePromptOnRefresh = False
- .TextFilePlatform = 950
- .TextFileStartRow = 1
- .TextFileParseType = xlFixedWidth
- .TextFileTextQualifier = xlTextQualifierDoubleQuote
- .TextFileConsecutiveDelimiter = False
- .TextFileTabDelimiter = True
- .TextFileSemicolonDelimiter = False
- .TextFileCommaDelimiter = False
- .TextFileSpaceDelimiter = False
- .TextFileColumnDataTypes = Array(9, 1, 9, 9)
- .TextFileFixedColumnWidths = Array(38, 32, 28)
- .TextFileTrailingMinusNumbers = True
- .Refresh BackgroundQuery:=False
- End With
- ActiveWindow.SmallScroll Down:=-27
- End Sub
複製代碼 |
|