我正在尝试从Windows下的.vbs文件运行以下代码,但无法运行它。我已经从我录制的宏中添加了一些命令,显然这不起作用。你能指出我正确的方向吗? (我意识到这一定是一个微不足道的问题)
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
答案 0 :(得分:0)
VBScript既不支持命名参数也不支持xl * constant,如下所示:
ws.Selection.Delete Shift:=xlUp