Excel宏 - 将工作表导出为以逗号分隔的CSV

时间:2015-08-13 08:03:22

标签: excel vba excel-vba csv

我有这个工作,除了我需要生成的文件特别是'windows逗号分隔CSV'文件。任何想法如何指定这个?

Sub asdf()
    Dim ws As Worksheet, newWb As Workbook

    Application.ScreenUpdating = False
    For Each ws In Sheets(Array("sheet1", "sheet2"))
       ws.Copy
       Set newWb = ActiveWorkbook
       With newWb
          .SaveAs ws.Name & ".csv", xlCSV
          .Close (False)
       End With
    Next ws
    Application.ScreenUpdating = True
End Sub

1 个答案:

答案 0 :(得分:3)

应该像将FileFormat指定为CSVWindows

一样简单

.SaveAs ws.Name & ".csv", xlCSVWindows