|
楼主 |
发表于 2014-4-2 18:22
|
显示全部楼层
cbtaja 发表于 2014-4-2 13:32
你好,非常感谢上面的大神,代码可以运行。
另外我从网上找了另外代码,测试可以成功转换为xls ,但是当我改一下代码,想转换为xlsx时却出错。请问为什么。谢谢。
附代码:
- Sub 格式转换()
- Dim FilePath, MyFile, iPath As String
- iPath = ThisWorkbook.Path
- MyFile = Dir(iPath & "\*.CSV")
- If MyFile <> "" Then
- Do
- On Error Resume Next
- If MyFile = ThisWorkbook.Name Then MyFile = Dir
- Workbooks.Open (iPath & "" & MyFile)
- MyFile = Replace(MyFile, ".csv", ".xls")
- Name = "" & MyFile
- FilePath = iPath & Name
- Application.ScreenUpdating = False
- ActiveWorkbook.SaveAs Filename:=FilePath, FileFormat:= _
- xlNormal, CreateBackup:=False
- Workbooks(MyFile).Close True
- Application.ScreenUpdating = True
- MyFile = Dir
- Loop While MyFile <> ""
- End If
- End Sub
复制代码
|
|