用vba,读一个txt文件,将读到的内容逐条写入到另一个文件中(后面这个文件要新建) 求高手帮忙

2024-11-15 22:28:46
推荐回答(1个)
回答1:

Sub 宏1()
Dim a As String
Dim fname As String
Dim fname2 As String
fname = "d:\123\123.txt"
fname2 = "d:\123\124.txt"
Open fname For Input As #1
Open fname2 For Output As #2
On Error Resume Next
Do
Input #1, a
Print #2, a
Loop While EOF(1) = False
Close #1
Close #2
End Sub

fname 你要读的文件
fname2 你要新建的文件名