|

楼主 |
发表于 2013-2-3 21:12
|
显示全部楼层
Sub hj()
Dim cFile$, cPath$, Sh As Worksheet, nRow%
Dim fullfile$
On Error GoTo error
Application.ScreenUpdating = False
Application.EnableEvents = False
cPath = ThisWorkbook.Path & "\"
cFile = Dir(cPath & "*.csv") ' 找寻第一个文件
Do While cFile <> ThisWorkbook.Name ' 开始循环。
fullfile = "C:\Documents and Settings\Administrator\桌面\Excel格式转换工具\555\" & Left(cFile, InStrRev(cFile, ".") - 1) & ".xlsx"
Workbooks.Open cPath & cFile '打开文件
ActiveWorkbook.SaveAs Filename:=fullfile, FileFormat:= _
xlOpenXMLWorkbook, CreateBackup:=False
'2007.xlsm (Fileformat:=xlOpenXMLWorkbookMacroEnabled)
ActiveWorkbook.Close '关闭文件
cFile = Dir ' 查找下一个文件
Loop
Application.EnableEvents = True
Application.ScreenUpdating = True
error:
Exit Sub
End Sub |
|