excel 批量格式转换
2016-06-21 11:52
337 查看
脚本运行方式
在需要转换的csv或者xls同目录新建一个xls文件,alt+f11打开VBA project,然后将代码贴入,点击运行即可。XLS批量转换为CSV
Sub xls2csv() Application.DisplayAlerts = False t = ActiveWorkbook.Name mypath = ActiveWorkbook.Path & "\" myfile = Dir(mypath & "*.xls") Do Until Len(myfile) = 0 If myfile <> t Then Workbooks.Open Filename:=mypath & myfile ActiveWorkbook.SaveAs Filename:=mypath & Left(myfile, InStr(myfile, ".") - 1) & ".csv", FileFormat:=xlCSV End If If myfile <> t Then ActiveWorkbook.Close myfile = Dir Loop Application.DisplayAlerts = True End Sub
CSV批量转XLS
Sub xls2csv() Application.DisplayAlerts = False t = ActiveWorkbook.Name mypath = ActiveWorkbook.Path & "\" myfile = Dir(mypath & "*.csv") Do Until Len(myfile) = 0 If myfile <> t Then Workbooks.Open Filename:=mypath & myfile ActiveWorkbook.SaveAs Filename:=mypath & Left(myfile, InStr(myfile, ".") - 1) & ".xls", FileFormat:=xlExcel8 End If If myfile <> t Then ActiveWorkbook.Close myfile = Dir Loop Application.DisplayAlerts = True End Sub
如有疑问,请留言。
相关文章推荐
- Ubuntu下的python的lxml库安装
- linux 最近使用的命令
- mac设置java环境变量, 使用oh-my-zsh
- ROS学习--语义理解NODE(NLU,NLP)
- php 发送验证码到邮箱
- Leetcode 252 meeting rooms
- iOS 类似美团外卖 app 两个 tableView 联动效果实现
- DB2备忘
- java https post (带证书的)
- centos/linux wdcp下修改php.ini无效的解决方案
- shp2sdo工具导入shp文件到oracle
- Python的*args与**kwargs
- angularjs 系列之$q和promise
- OkHttp官方api
- iOS 树状视图(折叠单元格)详细使用
- lua utf8 gbk 编码转换
- backface实现反转效果
- 什么是Serverless无服务器架构?
- 图文讲解CSS的Box Model盒模型中的边距
- 百度地图的配置