向txt中插入一行数据

Set abc = CreateObject("scripting.filesystemobject")
Set ntxt = abc.opentextfile("C:UsersAdministratorDesktop新建文本文档 (2).txt", 8, True)
ntxt.writeline """tempname"""
ntxt.Close
Set abc = Nothing
或者
Dim s As String, t As String, b() As Byte
s = Join([transpose(char(row(65:75)))], vbCrLf)'""tempname""
MsgBox s
Open "C:UsersAdministratorDesktop新建文本文档 (2).txt" For Binary As #1
ReDim b(LOF(1))
Get #1, , b
s = s & vbCrLf & StrConv(b, vbUnicode)
Put #1, 1, s
Close #1
Shell "notepad.exe C:UsersAdministratorDesktop新建文本文档 (2).txt", vbNormalFocus


//写入数据原来数据会没有
 Open "C:UsersAdministratorDesktop新建文本文档 (2).txt" For Output As #1
     strSQL = """tempname"""
     Print #1, strSQL
   Close #1

原文地址:https://www.cnblogs.com/bignine/p/10091019.html