I am writing a batch file and part of it converts .csv to .xlsx. I've been able to incorporate the solution from this post:
Convert .CSV to .XLSX using command line
Dim file, WB
With CreateObject("Excel.Application")
On Error Resume Next
For Each file In WScript.Arguments
Set WB = .Workbooks.Open(file)
WB.SaveAs Replace(WB.FullName, ".csv", ".xlsx"), 51
WB.Close False
Next
.Quit
End With
It works great, but the only issue is that I must pass an absolute path into the batch file to get it to work, like so:
CSV2XLSX.vbs C:\Users\Data\ktq\abc.csv
As explained in the original thread, it doesn't work just by doing the following:
CSV2XLSX.vbs abc.csv
This is a bit of a pain as if I move the folder I need to update the path. Is there any way I can force vbs to just take in the above command by correctly finding the file, or can I get the absolute path from the file in question and pass it in somehow? Any help would be great!