1. 程式人生 > >向txt中插入一行數據

向txt中插入一行數據

tin reat normal 原來 新建 scripting name 行數 一行

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

向txt中插入一行數據