1.工具中設定引用項目加入
a. Microsoft Script Control 1.0
b. Microsoft Scripting Runtime
2.新增函數
Function eliminateEmptyRow(fullName As String) As Boolean
Dim fso As New FileSystemObject, txtStr As TextStream, objOutputFile As _
TextStream, strText As String
If Dir(fullName) <> "" Then
Set txtStr = fso.OpenTextFile(fullName)
strText = txtStr.ReadAll
txtStr.Close
Else
eliminateEmptyRow = False: Exit Function
End If
strText = Left(strText, Len(strText) - 2)
Set objOutputFile = fso.CreateTextFile(fullName)
objOutputFile.Write strText
objOutputFile.Close
eliminateEmptyRow = True
End Function
3. 在你原始的副程式 .Close 下面加入下面呼叫
If Not eliminateEmptyRow(ThisWorkbook.Path & "\" & k(i) & ".csv") Then Stop
※ 引述《gone19 (gone19)》之銘言:
: *[1;33m(若是和其他不同軟體互動之問題 請記得一併填寫)*[m
: 軟體:Office Excel
: 版本:2021
: 我從網路上找到VBA CODE並更改一下
: 以某一行當基準分割為多個檔案
: 把AH欄位刪除,轉換成CSV檔
: 但轉出來的CSV檔都會多一列空白列
: 可否用VBA把這列去除?或在這個CODE裡多寫什麼?
: 謝謝!
: