|
楼主 |
发表于 2013-2-3 20:44
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Option Explicit
Sub hj()
Dim cFile$, cPath$, Sh As Worksheet, nRow%
Dim fullfile$
Dim p As String
Application.ScreenUpdating = False
Application.EnableEvents = False
cPath = ThisWorkbook.Path & "\"
cFile = Dir(cPath & "*.csv") ' 找寻第一个文件
p = "C:\Documents and Settings\Administrator\桌面\Excel格式转换工具\555\"
Do While cFile <> ThisWorkbook.Name ' 开始循环。
fullfile = p & Left(cFile, InStrRev(cFile, ".") - 1) & ".xlsx"
Workbooks.Open cPath & cFile '打开文件
ActiveWorkbook.SaveAs Filename:=fullfile, FileFormat:= _
xlWorkbookNormal, CreateBackup:=False
'2007.xlsm (Fileformat:=xlOpenXMLWorkbookMacroEnabled)
ActiveWorkbook.Close '关闭文件
cFile = Dir ' 查找下一个文件
Loop
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
重新写成了这种形式,这样确实把原文件另存到指定文件夹下,但为什么生成的文件打不开,显示格式扩展名无效? |
|