|
楼主 |
发表于 2018-8-28 11:22
|
显示全部楼层
Sub readme()
Dim mypath As String
Dim stxt As String
Dim arr
Dim i
Dim sh As Worksheet
With Application.FileDialog(msoFileDialogFilePicker) 'Îļt¶Ô»°¿ò
.AllowMultiSelect = True
.Filters.Clear
.Filters.Add "Îı¾ÎÄμμ", "*.txt"
If .Show = -1 Then 'èç1ûÑ¡ÔñáËÎļt
For i = 1 To .SelectedItems.Count 'Ñ-»·Ã¿¸öTXTÎļt
mypath = .SelectedItems(i)
'mypath = "è«Â·¾¶ÎļtÃû"
Open mypath For Input As #1
stxt = StrConv(InputB(LOF(1), 1), vbUnicode) '¶áè¡TXTÄúèY
arr = Split(stxt, " =") 'SPLIToˉêy2e·Ö
Debug.Print Val(Split(arr(1), vbCr)(0))
Sheets("Template").Copy After:=Sheets(Sheets.Count) '¸′ÖÆò»·YÄ£°å '(after:=Worksheets(Worksheets.Count))
Set sh = Sheets(Sheets.Count)
sh.Name = Split(Mid(mypath, InStrRev(mypath, "\") + 1, 99), ".txt")(0) '1¤×÷±íÃû3Æ
sh.Cells(6, "I") = Split(Mid(mypath, InStrRev(mypath, "\") + 1, 99), ".txt")(0) 'txtÎļtÃû
sh.Cells(22, 3) = Val(Split(arr(1), vbCr)(0)) '¶Ôó|μÄêy×ÖD′èëμ½μ¥Ôa¸ñ
sh.Cells(22, 4) = Val(Split(arr(2), vbCr)(0))
sh.Cells(22, 6) = Val(Split(arr(3), vbCr)(0))
sh.Cells(22, 7) = Val(Split(arr(4), vbCr)(0))
sh.Cells(22, 9) = Val(Split(arr(5), vbCr)(0))
sh.Cells(22, 10) = Val(Split(arr(6), vbCr)(0))
sh.Cells(22, 13) = Val(Split(arr(7), vbCr)(0))
sh.Cells(22, 15) = Val(Split(arr(8), vbCr)(0)) ' ÕaêÇ22DD 8¸öêy¾Y 6.0
sh.Cells(23, 3) = Val(Split(arr(9), vbCr)(0))
sh.Cells(23, 4) = Val(Split(arr(10), vbCr)(0))
sh.Cells(23, 6) = Val(Split(arr(11), vbCr)(0))
sh.Cells(23, 7) = Val(Split(arr(12), vbCr)(0))
sh.Cells(23, 9) = Val(Split(arr(13), vbCr)(0))
sh.Cells(23, 10) = Val(Split(arr(14), vbCr)(0))
sh.Cells(23, 13) = Val(Split(arr(15), vbCr)(0))
sh.Cells(23, 15) = Val(Split(arr(16), vbCr)(0)) ' ÕaêÇ23DD 8¸öêy¾Y 6.0
sh.Cells(30, 3) = Val(Split(arr(17), vbCr)(0))
sh.Cells(30, 4) = Val(Split(arr(18), vbCr)(0))
sh.Cells(30, 6) = Val(Split(arr(19), vbCr)(0))
sh.Cells(30, 7) = Val(Split(arr(20), vbCr)(0))
sh.Cells(30, 9) = Val(Split(arr(21), vbCr)(0))
sh.Cells(30, 10) = Val(Split(arr(22), vbCr)(0))
sh.Cells(30, 13) = Val(Split(arr(23), vbCr)(0))
sh.Cells(30, 15) = Val(Split(arr(24), vbCr)(0)) 'ÕaêÇ30DD 8¸öêy¾Y 18.05
sh.Cells(26, 3) = Val(Split(arr(25), vbCr)(0)) 'μú25¸öêy¾YD′èë
sh.Cells(27, 3) = Val(Split(arr(26), vbCr)(0)) 'ÕaêÇμú26¸öêy¾YD′èë
sh.Cells(26, 4) = Val(Split(arr(27), vbCr)(0))
sh.Cells(27, 4) = Val(Split(arr(28), vbCr)(0))
sh.Cells(26, 6) = Val(Split(arr(29), vbCr)(0))
sh.Cells(27, 6) = Val(Split(arr(30), vbCr)(0))
sh.Cells(26, 7) = Val(Split(arr(31), vbCr)(0))
sh.Cells(27, 7) = Val(Split(arr(32), vbCr)(0)) '27,26DDêy¾YD′èëÇ°4¸ö
sh.Cells(26, 9) = Val(Split(arr(33), vbCr)(0))
sh.Cells(27, 9) = Val(Split(arr(34), vbCr)(0))
sh.Cells(26, 10) = Val(Split(arr(35), vbCr)(0))
sh.Cells(27, 10) = Val(Split(arr(36), vbCr)(0))
sh.Cells(26, 13) = Val(Split(arr(37), vbCr)(0))
sh.Cells(27, 13) = Val(Split(arr(38), vbCr)(0))
sh.Cells(26, 15) = Val(Split(arr(39), vbCr)(0))
sh.Cells(27, 15) = Val(Split(arr(40), vbCr)(0)) '26£¬27DDêy¾Yoó4¸öD′èë
sh.Cells(28, 3) = Val(Split(arr(41), vbCr)(0))
sh.Cells(29, 3) = Val(Split(arr(42), vbCr)(0)) 'ÕaêÇ28,29êy¾YD′èë
sh.Cells(28, 4) = Val(Split(arr(43), vbCr)(0))
sh.Cells(29, 4) = Val(Split(arr(44), vbCr)(0))
sh.Cells(28, 6) = Val(Split(arr(45), vbCr)(0))
sh.Cells(29, 6) = Val(Split(arr(46), vbCr)(0))
sh.Cells(28, 7) = Val(Split(arr(47), vbCr)(0))
sh.Cells(29, 7) = Val(Split(arr(48), vbCr)(0))
sh.Cells(28, 9) = Val(Split(arr(49), vbCr)(0))
sh.Cells(29, 9) = Val(Split(arr(50), vbCr)(0))
sh.Cells(28, 10) = Val(Split(arr(51), vbCr)(0))
sh.Cells(29, 10) = Val(Split(arr(52), vbCr)(0))
sh.Cells(28, 13) = Val(Split(arr(53), vbCr)(0))
sh.Cells(29, 13) = Val(Split(arr(54), vbCr)(0))
sh.Cells(28, 15) = Val(Split(arr(55), vbCr)(0))
sh.Cells(29, 15) = Val(Split(arr(56), vbCr)(0))
Close #1 '1رÕTXTÎÄμμ
'Debug.Print stxt
Next i
End If
End With
End Sub
|
|