|
Private Sub CommandButton6_Click() ''文件转化
Application.ScreenUpdating = False
Dim m, filesload, froad As String
Dim nfile, i As Integer
Const forreading = 1, forwriting = 2, forappending = 3
Const tristateusedefault = -2, tristatetrue = -1, tristatefalse = 0
Dim fs, f, ts, s
If (ListBox2.ListCount) = 0 Then
MsgBox "没有可选择表执行!"
Exit Sub
End If
Application.DisplayAlerts = False
For nfile = 0 To ListBox2.ListCount - 1
m = ListBox2.List(nfile)
filesload = Left(ActiveWorkbook.FullName, (Len(ActiveWorkbook.FullName) - Len(ActiveWorkbook.Name)))
froad = filesload & m
'''打开txtfile表
Set fs = CreateObject("scripting.filesystemobject")
Set f = fs.getfile(froad)
Set ts = f.openastextstream(forreading, tristatefalse)
Do While ts.AtEndOfstream <> True
s = ts.readline
i = i + 1
Sheet1.Cells(i, 1) = Trim(s)
Loop
ts.Close
'Workbooks.Open (froad)
'Application.Visible = False
Next nfile
Application.ScreenUpdating = True
End Sub |
|