Option Explicit
Sub test()
Dim thispath As String, mytxt As String, s, tm, br(), i&, j&
thispath = ThisWorkbook.Path & "\"
mytxt = Dir(thispath & "*.txt")
Open thispath & mytxt For Input As #1
tm = Split(StrConv(InputB(LOF(1), #1), vbUnicode), vbCrLf)
Close #1
For i = 0 To UBound(tm)
s = Split(tm(i), ",")
If i = 0 Then ReDim br(UBound(tm), UBound(s))
For j = 1 To UBound(s)
br(i, j) = s(j)
Next j
br(i, 0) = "'" & s(0)
Next i
Sheet3.[a1].Resize(i, j) = br
End Sub
补充内容 (2016-10-30 11:02):
Sub test1()
Dim thispath As String, mytxt As String, s, tm, br(), i&, j&, ad
Set ad = CreateObject("adodb.stream")
With ad
.Charset = "utf-8"
.Type = 2
.Open
.LoadFromFile ThisWorkbook.Path & "\@Template.htm"
tm = .ReadText
.Close
End With
tm = Split(tm, vbCrLf)
For i = 0 To UBound(tm)
Cells(i + 1, 1) = tm(i)
Next i
End Sub
补充内容 (2016-12-8 11:33):
Sub getdata()
Dim rst As Object, StrConn As String, arr As Variant
Set rst = VBA.CreateObject("ADODB.Recordset")
StrConn = "Provider=Microsoft.ace.OLEDB.12.0;Extended Properties='" _
+ "text;hdr=yes';data source=" & ThisWorkbook.Path & "\"
rst.Open "d1.txt", StrConn, 1, 3
rst.Move 1
arr = rst.GetRows()
rst.Close
MsgBox UBound(arr)
MsgBox UBound(arr, 2)
[a1:g1] = arr
Set rst = Nothing
End Sub