Created
November 8, 2012 16:20
-
-
Save yanping/4039836 to your computer and use it in GitHub Desktop.
批量转换xls为csv的VBA代码
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'批量转换文件夹中的xls为csv | |
'地址 http://www.cnblogs.com/snippet/archive/2010/07/06/xls2csv.html | |
Option Explicit | |
Sub covertFile(ByRef sFilename As String) | |
Dim oWorkbook As Workbook | |
Set oWorkbook = Workbooks.Open(Filename:=sFilename) | |
oWorkbook.SaveAs Filename:=sFilename & ".csv", FileFormat:= _ | |
xlCSV, CreateBackup:=False | |
oWorkbook.Close False | |
End Sub | |
Sub covertFiles() | |
Dim sPath As String | |
Dim sDir As String | |
sPath = "K:\Desktop\List" | |
sDir = Dir(sPath & "\*.xls") | |
While Len(sDir) | |
Debug.Print sDir | |
covertFile sPath & "\" & sDir | |
sDir = Dir | |
Wend | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://club.excelhome.net/thread-905812-1-1.html 不知有没有用