码迷,mamicode.com
首页 > 其他好文 > 详细

向txt中插入一行数据

时间:2018-12-09 16:34:53      阅读:360      评论:0      收藏:0      [点我收藏+]

标签:not   char   join   exe   notepad   scripting   for   focus   orm   

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中插入一行数据

标签:not   char   join   exe   notepad   scripting   for   focus   orm   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!