Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) '等待dwMilliseconds毫秒
Sub 按值输出所有表()
Dim FileName As String
Dim iFNum As Integer
Dim Row, Column As Long
Dim Sheet As Excel.Worksheet
Application.StatusBar = "正在处理..."
For Each Sheet In ActiveWorkbook.Sheets
With Sheet
Row = .UsedRange.Rows.Count '获得工作表使用区域的行数
Column = .UsedRange.Columns.Count '获得工作表使用区域的列数
iFNum = FreeFile
BookName = Mid(ActiveWorkbook.FullName, 1, Len(ActiveWorkbook.FullName) - 4)
If Dir(BookName, vbDirectory) = "" Then MkDir (BookName)
FileName = BookName & "\" & .Name & ".txt"
Open FileName For Output As #iFNum
For i = 1 To Row
For j = 1 To Column
Print #iFNum, .Cells(i, j).Value,
'Print #iFNum, Cells(i, j).Text,
Next j
Print #iFNum,
Next i
Close #iFNum
End With
Next Sheet
Application.StatusBar = "数据已全部从Excel导入文本文档,程序结束!"
Sleep 1000
Application.StatusBar = False
End Sub