思路如下1、选择文件路径2、以下方法是清空文本文件用的Sub mysub() Const ForReading = 1,Scripting.FileSystemObject"\1.txt"
VBA怎么删除文本文件?
思路如下1、选择文件路径2、以下方法是清空文本文件用的Sub mysub() Const ForReading = 1, ForWriting = 2, ForAppending = 8 Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0 Dim fso, f, ts Set fso = CreateObject("Scripting.FileSystemObject"
) Dim fullName As String fullName = "D:.txt" fso.createtextfile fullName Set f = fso.getfile(fullName) Set ts = f.openastextstream(ForWriting, TristateTrue) ts.write "你好" ts.Close Set ts = Nothing Set f = Nothing Set fso = NothingEnd Sub3整个文件删除用 kill文件名 就可以。
0