Sub 创建文本文件()
Dim astr(1 To 3) As String, i As Integer
Dim sfname As String, ifnumber As Integer, r As Long
sfname = Application.InputBox(prompt:="请输入文本文件的名称", _
Title:="输入文件名称", Type:=2)
If sfname = "False" Or sfname = "" Then Exit Sub
sfname = ThisWorkbook.Path & "\" & sfname & ".txt"
ifnumber = FreeFile
Open sfname For Output As #ifnumber
r = 2
Do
With Sheet1
For i = 1 To 3
astr(i) = .Cells(r, i)
Next
End With
Write #ifnumber, astr(1), astr(2), astr(3)
r = r + 1
Loop Until IsEmpty(Sheet1.Cells(r, 1))
Close #ifnumber
End Sub