我在文件夹中有几个“.xls”文件,需要将其转换为制表符分隔值 找到了一个用于此的vb脚本..请使用某些主体sugest如何执行此操作? 我得到几个错误时运行this.I我不是一个VB programmer.Experts ......请帮助将xls文件转换为制表符分隔文件的异常
Public Sub Main()
Dim WScript As Object = Nothing '' with out nothing it was showing an error
Dim oExcel As Object
Dim oBook As Object
If WScript.Arguments.Count < 2 Then
WScript.Echo("Error! Please specify the source path and the destination. Usage: XlsToCsv SourcePath.xls Destination.csv")
Wscript.Quit()
End If
oExcel = CreateObject("Excel.Application")
oBook = oExcel.Workbooks.Open(WScript.Arguments.Item(0)) ''item o might be excel
oBook = oExcel.Workbooks.Open("C:\Users\5A5.xls")
oBook.SaveAs(WScript.Arguments.Item(1), -4158)
oBook.Close(False)
oExcel.Quit()
WScript.Echo("Done")
End Sub
例外:
System.Reflection.TargetInvocationException:
Exception has been thrown by the target of an invocation.
---> System.NullReferenceException: Object variable or With block variable not set.
你可能已经至少表明,这些“错误” ...:P – AKDADEVIL
错误:System.Reflection.TargetInvocationException:异常已通过调用的目标引发异常。 ---> System.NullReferenceException:对象变量或未设置块变量。 – user1254579