返回列表 上一主題 發帖

[轉貼] 請問VBA於EXCEL新增文字檔案+日期

Sub 產生文字檔()
xT = "文字檔內容"
xFile = thisworkbook.path & "\" & format(date,"yyyymmdd") & ".txt"
Open xFile For Output As #1  'Output覆蓋舊資料
Print #1, xT
Close #1
End Sub

TOP

Sub 產生文字檔_2()
xT = "文字檔內容"
xFile = thisworkbook.path & "\" & format(date,"yyyymmdd") & ".txt"
Open xFile For Append As #1  'Append-寫在檔案的尾端...累增
Print #1, xT
Close #1
End Sub

TOP

另外, 可搜下面兩種方法//
CreateObject("Scripting.FileSystemObject") + OpenTextFile
CreateObject("ADODB.Stream")

TOP

        靜思自在 : 慈悲沒有敵人,智慧不起煩惱。
返回列表 上一主題