vba写txt文件
用vba往txt文件中写东西,怎么样能从空白行开始写?不覆盖原来txt文件中存在的东西 vba
[解决办法]
Sub test1111()
Dim fso, sFile
Dim str, filepath, filename As String
Dim linecount As Integer
filepath = "d:\"
filename = "1.txt"
Const ForReading = 1, ForWriting = 2, ForAppending = 8, TristateFalse = 0 'ForAppending从文件末尾追加
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(filepath & filename) = True Then
Set sFile = fso.OpenTextFile(filepath & filename, ForAppending, TristateFalse)
sFile.Write ("Hello world!")
'sFile.Writeline ("Hello world!")
sFile.Close
End If
Set fso = Nothing
Set sFile = Nothing
End Sub