I am attempting to convert around 600 excel files in a directory into CSV, so that they are in a standardised format for SAS Enterprise guide.
To do this, I have a batch file that performs a VBScript on each .xlsx file in the directory. This works for almost all of the excel files, except for the files that are 'corrupted'.
I'm not sure why they're corrupted, but they have all been converted from Google Sheets to Excel, so it's no surprise.
My problem is that the syntax that is supposed to force the workbooks.open() method to open a corrupted file is not working.
Please see my vbs code below:
csv_format = 6
Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim oExcel
Set oExcel = CreateObject("Excel.Application")
Dim oBook
Set oBook = oExcel.Workbooks.Open ("Z:\ATR_Track\0108~ASHFORD TP~AT-ATv2~18-06-2018.xlsx", CorruptLoad:= xlRepairFile)
oBook.Sheets(WScript.Arguments.Item(0)).Select
set deleterange = oExcel.Range("A1", "A3").EntireRow
deleterange.AutoFilter()
deleterange.Delete
oBook.SaveAs "Z:\ATR_Track\test.csv" &"_ATR",
csv_format
oBook.Close False
oExcel.Quit
The error that is returned reads "Expected ')'" at line 9, character 129.
Can anyone tell me what's wrong with my syntax?