- '将 XLS 文件拖到此 VBS 中,将生成同名 TXT 文本文件。
- Filename = WScript.Arguments(0)
- Set ExcelApp = CreateObject("Excel.Application")
- Set ExcelOut = ExcelApp.Workbooks.Open(Filename)
- If LCase(Right(Filename,4))=".xls" Then
- RowC = ExcelOut.WorkSheets(1).UsedRange.Rows.Count
- For i = 2 to ExcelOut.WorkSheets.Count
- ExcelOut.WorkSheets(i).UsedRange.Copy
- ExcelOut.WorkSheets(1).Range("A" & RowC + 1).PasteSpecial
- RowC = RowC + ExcelOut.WorkSheets(i).UsedRange.Rows.Count
- Next
- ExcelOut.WorkSheets(1).SaveAs Left(Filename,instrrev(Filename,".")) & "TXT",3
- End If
- ExcelOut.Saved = True
- ExcelOut.Close
- Wscript.Quit
复制代码
|