VBA建立文字檔案、讀寫文字檔案
阿新 • • 發佈:2019-01-05
轉自:http://blog.csdn.net/merry1205/article/details/5786273Private Sub CommandButton1_Click() Dim gPath As String Dim sFile As Object, Fso As Object gPath = Application.ActiveWorkbook.Path Set Fso = CreateObject("Scripting.FileSystemObject") Set sFile = Fso.CreateTextFile(gPath & "/TestFile.txt", True) sFile.WriteLine ("CreateTextFile Test") sFile.WriteLine ("CreateTextFile Test1") sFile.WriteLine ("CreateTextFile Test2") sFile.WriteLine ("CreateTextFile Test2") sFile.Close Set sFile = Nothing Set Fso = Nothing End Sub