向txt中插入一行数据

Set abc = CreateObject("scripting.filesystemobject")
Set ntxt = abc.opentextfile("C:\Users\Administrator\Desktop\新建文本文档 (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:\Users\Administrator\Desktop\新建文本文档 (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:\Users\Administrator\Desktop\新建文本文档 (2).txt", vbNormalFocus


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

posted @ 2018-12-09 14:04  小九家的丫头  阅读(562)  评论(0编辑  收藏  举报