EXECL批量转CSV 生成1 2 3 。。。 文件名

Sub SaveToCSVs()

Dim fDir As String

Dim wB As Workbook

Dim wS As Worksheet

Dim fPath As String

Dim sPath As String
Dim i, j, k As Integer

fPath = “\\data\www\fs_audit\joom\allFiles\”

sPath = “\\data\www\fs_audit\joom\”

fDir = Dir(fPath)

Do While (fDir <> “”)

If Right(fDir, 4) = “.xls” Or Right(fDir, 5) = “.xlsx” Then

On Error Resume Next

Set wB = Workbooks.Open(fPath & fDir)

‘MsgBox (wB.Name)

For Each wS In wB.Sheets

wS.SaveAs sPath & i & “.csv”, xlCSV
i = i + 1

Next wS

wB.Close False

Set wB = Nothing

End If

fDir = Dir

On Error GoTo 0

Loop

End Sub

发表评论

电子邮件地址不会被公开。 必填项已用*标注