(若是和其他不同軟體互動之問題 請記得一併填寫)
軟體:excel
版本:2016
各位好,初入VBSA
參考版上的批量xls轉csv
做了一些修改
因為轉存的csv會依照原本xls檔名來取sheet名稱
能否轉出csv時,sheet的名稱想同步取名為"sheet0"
或者是能夠依照原本xls的sheet名稱同步移植過去?
Option Explicit
Sub Ex()
Dim xlpath As String, xlfile As String
Dim xlpathout As String
xlpath = "D:\研4\" '要轉檔路徑
xlpathout = xlpath & "csv\" '轉檔儲存路徑
MkDir xlpath & "csv\" '創轉檔存的資料夾
xlfile = Dir(xlpath & "*.xls")
Do While xlfile <> ""
With Workbooks.Open(xlpath & xlfile)
.SaveAs Filename:=xlpathout & Replace(xlfile, "xls", ".csv"),
FileFormat:=xlCSV
.Close SaveChanges:=True '關閉 檔案 ,存檔
End With
xlfile = Dir
Loop
End Sub