本帖最后由 pcl_test 于 2016-7-31 21:51 编辑
下面的代码是xls转csv的,求修改成点击一下VBS一个步骤完成:把文件夹下面的所有xls,按原来的前缀文件名转成csv- Const xlCSV = 6
-
- dim filepathname
- Set objExcel = CreateObject("Excel.Application")
- Filename = objExcel.GetOpenFilename("Excel Files (*.xls), *.xls")
- objExcel.DisplayAlerts=FALSE
- If filename<>false Then
- On Error Resume Next
- Set objWorkbook = objExcel.Workbooks.Open(Filename)
- If Err.Number <> 0 Then
- Err.Raise Err.Number
- Return "-1"
- End If
- objWorkbook.SaveAs mid(Filename,1,len(Filename)-4) & ".csv",xlCSV
- If Err.Number <> 0 Then
- Err.Raise Err.Number
- Return "-1"
- End If
- 'MsgBox objWorkbook.path
- filepathname = objWorkbook.path & "\\" & mid(Filename,1,len(Filename)-4) & ".csv"
- objWorkbook.close
- End If
- objExcel.Quit
- 'MsgBox filepathname
- If filepathname>"" then
- Return filepathname
- end if
复制代码
|