I am trying to run the following code from a .vbs file under Windows, but cannot get it to run. I have added some commands from a macro I recorded, and apparently that does not work. Could you point me in the right direction? (I realize this must be a trivial problem)
Set fso = CreateObject("Scripting.FileSystemObject")
Set xl = CreateObject("Excel.Application")
xl.Visible = True
For Each f In fso.GetFolder("C:\Temp").Files
If LCase(fso.GetExtensionName(f.Name)) = "xlsm" Then
Set wb = xl.Workbooks.Open(f.Path)
Set ws = wb.Worksheets("Data")
' make sure number formatting is OK
ws.Cells.Select
ws.Selection.NumberFormat = "General"
' kill header row
ws.Rows("1:1").Select
ws.Selection.Delete Shift:=xlUp
' save output as CSV
wb.SaveAs Filename:= f.Path & ".csv", FileFormat:= xlCSVMSDOS, CreateBackup:=False
wb.Close
End If
Next
xl.Quit
VBScript does neither supports named arguments nor xl* constant as in your:
See named/positional args, consts, other.