Saturday, September 18, 2010

File handling with VBA

Open File 1 and write to File 2
Open "C:\File1.txt" For Input As #1
Open "C:\File2.txt" For Append As #2    ‘ or Output
    While Not EOF(1)
    Input #1, CompLine
    Print #2, CompLine
    Wend
Close 2
Close 1


Find a file and delete if exist
If Dir$("C:\temp\Comp_list.txt") = "Comp_list.txt" Then
    Kill "C:\temp\Comp_list.txt"
End If

No comments:

Post a Comment

Please add if your have better information.